Code::Blocks Forums

Developer forums (C::B DEVELOPMENT STRICTLY!) => Development => Topic started by: pece on October 05, 2009, 09:09:59 am

Title: CMD_NULL macro (macrosmanager.cpp)
Post by: pece 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
Title: Re: CMD_NULL macro (macrosmanager.cpp)
Post by: MortenMacFly 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?
Title: Re: CMD_NULL macro (macrosmanager.cpp)
Post by: pece 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
Title: Re: CMD_NULL macro (macrosmanager.cpp)
Post by: stahta01 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.


Title: Re: CMD_NULL macro (macrosmanager.cpp)
Post by: pece 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
Title: Re: CMD_NULL macro (macrosmanager.cpp)
Post by: stahta01 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.
Title: Re: CMD_NULL macro (macrosmanager.cpp)
Post by: 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.
Title: Re: CMD_NULL macro (macrosmanager.cpp)
Post by: pece 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