How to determine if errno_t is defined?

I compile the code using gcc, which comes with Visual C ++ 2008. The code uses errno_t, but in some versions of gcc headers, including <errno.h>, it does not determine the type. How to determine if a type is specified? Is there a definition that signals that a type is defined? In case it is not defined, I would like to provide a typedef so that the code compiles correctly on all platforms.

+5
source share
4 answers

You cannot check the typedef as you can for the macro, so this is a bit complicated. If you use autoconf, this patch shows the minimal changes that autoconf needs to check for availability errno_tand determine if it is missing (typedef will be placed in a file containing your generated one config.hand included with all files that need it errno_t). If you are not using autoconf, you need to come up with some way to do the same in your build system or a very smart set of tests against macros of the compiler version.

+2
source

Microsoft errno_t . errno ISO C l int. errno, int.

s/errno_t/int/, .

: , typedef int errno_t , , _t, .

+6

, , , GNU autoconf . autoconf script, , . C .

0

If you know which versions of GCC are giving you problems, you can check them out. You can check out GCC versions using something like:

  #if __GNUC__ == 3
  ...
  #else
  ...
  #endif
0
source

All Articles