Author Topic: CMD_NULL macro (macrosmanager.cpp)  (Read 6606 times)

Offline pece

  • Single posting newcomer
  • *
  • Posts: 4
CMD_NULL macro (macrosmanager.cpp)
« on: October 05, 2009, 09:09:59 am »
Hello,

line 113 in macrosmanager.cpp should be:
macros[_T("CMD_NULL")]  = _T("NUL");

How about adding macro for $(CMD) = "cmd /c" on windows, "sh" otherwise?

Przemek

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: CMD_NULL macro (macrosmanager.cpp)
« Reply #1 on: October 05, 2009, 09:49:45 am »
macros[_T("CMD_NULL")]  = _T("NUL");
Why???

How about adding macro for $(CMD) = "cmd /c" on windows, "sh" otherwise?
For what purpose?
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline pece

  • Single posting newcomer
  • *
  • Posts: 4
Re: CMD_NULL macro (macrosmanager.cpp)
« Reply #2 on: October 05, 2009, 10:59:08 am »
macros[_T("CMD_NULL")]  = _T("NUL");
Why???

Because for the rest of platforms CMD_NULL macro is defined as a file: /dev/null
See macrosmanager.cpp line 122:

macros[_T("CMD_NULL")]  = _T("/dev/null");

Then it would be possible to use it for example in pre-build command:
$(CMD_CP) include.hw include.h > $(CMD_NULL)

CMD_NULL in its current state on windows platforms expands to invalid command:
cmd /c NUL

How about adding macro for $(CMD) = "cmd /c" on windows, "sh" otherwise?
For what purpose?

For purpose the macros are for: to parametrize things.

Przemek

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7591
    • My Best Post
Re: CMD_NULL macro (macrosmanager.cpp)
« Reply #3 on: October 05, 2009, 02:27:17 pm »
Did you try it?

Code
dir > NUL

Does not error out for me.

See http://en.wikipedia.org/wiki//dev/null

Tim S.


C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline pece

  • Single posting newcomer
  • *
  • Posts: 4
Re: CMD_NULL macro (macrosmanager.cpp)
« Reply #4 on: October 05, 2009, 04:14:22 pm »
Did you try it?

Code
dir > NUL

Does not error out for me.

See http://en.wikipedia.org/wiki//dev/null

Tim S.


Tim, please read the whole thread. You should test it with "dir > cmd /c NUL"
as this is what $(CMD_NULL) macro expands to, on windows, curently.

(Should expand to plain "NUL" not "cmd /c NUL").

Przemek

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7591
    • My Best Post
Re: CMD_NULL macro (macrosmanager.cpp)
« Reply #5 on: October 05, 2009, 05:08:35 pm »
Did you try it?

Code
dir > NUL

Does not error out for me.

See http://en.wikipedia.org/wiki//dev/null

Tim S.


Tim, please read the whole thread. You should test it with "dir > cmd /c NUL"
as this is what $(CMD_NULL) macro expands to, on windows, curently.

(Should expand to plain "NUL" not "cmd /c NUL").

Przemek

You only stated the issue clearly in this message; I had no idea what you were saying in about 1 in 3 sentences.

Edit: And this does work. So, another possible solution.
"cmd /c > NUL dir"


Tim S.
« Last Edit: October 05, 2009, 05:13:39 pm by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: CMD_NULL macro (macrosmanager.cpp)
« Reply #6 on: October 06, 2009, 12:05:35 pm »
He's right with his first point, though. I admit that I had difficulties understanding, too, but he's right :)

The other thing (adding sh under Unix) is not necessary, as it works fine with the default shell which is user-configurable.
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline pece

  • Single posting newcomer
  • *
  • Posts: 4
Re: CMD_NULL macro (macrosmanager.cpp)
« Reply #7 on: October 06, 2009, 12:19:45 pm »
He's right with his first point, though. I admit that I had difficulties understanding, too, but he's right :)

The other thing (adding sh under Unix) is not necessary, as it works fine with the default shell which is user-configurable.

C::B doesn't have macro for invoking command interpreter. Hence $(CMD) would be usefull.
Pre(post) build steps could benefit from this. And 'sh' is most neutral on non-windowses.
Or it could just yield the value that user has configured in default shell setting.

Przemek
« Last Edit: October 06, 2009, 12:47:43 pm by pece »