0

Is using __MSDOS__ enough with djgpp or should __DJGPP__ be used instead?

By comparison, I know _WIN32 isn’t defined by default on cygwin (based on the assumption djgpp and cygwin have the purpose to build an Unix layer to hide real OS details).

I no longer have a DOS machine to test it.

Jens
  • 69,818
  • 15
  • 125
  • 179
user2284570
  • 2,891
  • 3
  • 26
  • 74
  • This is not a website where people read the manual of your compiler because you can't be bothered. Since most of us aren't writing DOS programs for our day job this is not something anyone is likely to know by heart. You will have to roll up your sleeves and RTFM. – jforberg Apr 19 '16 at 22:41
  • Not sure, but https://sourceforge.net/p/predef/wiki/OperatingSystems/#msdos suggests there are multiple macros to test. I know Bruce's C compiler defines `__MSDOS__`. Maybe DJGPP does, but Turbo C uses one of the others (or vice versa)? [Another site](http://jesusnjim.com/programming/common-compiler-defines.html#djgpp) says yes. In the future, Google will save you some time: _ predefined macros_. –  Apr 19 '16 at 22:45
  • @jforberg : I’m afraid http://www.delorie.com/djgpp doesn’t state it clearly. and binutils use both`__MSDOS__`and`__DJGPP__` – user2284570 Apr 19 '16 at 22:49
  • @ChronoKitsune : *(not related to the current question)* so according to [the site you found](https://sourceforge.net/p/predef/wiki/OperatingSystems/), you suggest that`_WIN32`isn’t defined on 16 bit in favor of`_WIN16`? – user2284570 Apr 19 '16 at 22:59
  • 1
    @user2284570 Yes, that's correct. [Microsoft confirms this briefly](https://msdn.microsoft.com/en-us/library/ff540443.aspx). That being said, I'm not sure why you'd want to target Win16 environments or any version of DOS... –  Apr 19 '16 at 23:13
  • If you are not targeting DOS why are you using DJGPP? – Matteo Italia Apr 19 '16 at 23:20
  • @MatteoItalia : I’m targeting security auditing in binutils source code *(check for path traversal)*. – user2284570 Apr 19 '16 at 23:49
  • you may get a DOS to test it with FreeDOS. – jarnosz Apr 20 '16 at 21:05

1 Answers1

1

To list the predefined macros and their values, use

djgpp -E -x c -dM /dev/null
Jens
  • 69,818
  • 15
  • 125
  • 179