News:

The new Release 25.03 is out! You can download binaries for Windows and many major Linux distros here .

Main Menu

CMD_NULL macro (macrosmanager.cpp)

Started by pece, October 05, 2009, 09:09:59 AM

Previous topic - Next topic

pece

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

MortenMacFly

Quote from: pece on October 05, 2009, 09:09:59 AM
macros[_T("CMD_NULL")]  = _T("NUL");
Why???

Quote from: pece on October 05, 2009, 09:09:59 AM
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: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

pece

Quote from: MortenMacFly on October 05, 2009, 09:49:45 AM
Quote from: pece on October 05, 2009, 09:09:59 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

Quote from: MortenMacFly on October 05, 2009, 09:49:45 AM
Quote from: pece on October 05, 2009, 09:09:59 AM
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

stahta01

Did you try it?

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++.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. [url="http://wiki.codeblocks.org"]http://wiki.codeblocks.org[/url]

pece

Quote from: stahta01 on October 05, 2009, 02:27:17 PM
Did you try it?

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

stahta01

#5
Quote from: pece on October 05, 2009, 04:14:22 PM
Quote from: stahta01 on October 05, 2009, 02:27:17 PM
Did you try it?

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.
C Programmer working to learn more about C++.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. [url="http://wiki.codeblocks.org"]http://wiki.codeblocks.org[/url]

thomas

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."

pece

#7
Quote from: thomas 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.

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