O
Oodini
Hello,
Could anyone explain me the following preprocessor sentences:
----------------------------------------------------------------
#if (defined(__STDC__) && !defined(NO_PROTOTYPE)) || defined(__cplusplus)
# define _USING_PROTOTYPES_ 1
# define _ANSI_ARGS_(x) x
# define CONST const
# ifdef __cplusplus
# define VARARGS (...)
# else
# define VARARGS ()
# endif
#else
# define _ANSI_ARGS_(x) ()
# define CONST
#endif
#undef EXTERN
#ifdef __cplusplus
# define EXTERN extern "C"
#else
# define EXTERN extern
#endif
-----------------------------------------------------------------
I know that __STDC__ means: "the compiler is C compatible"
I know that __cplusplus means: "the compiler does C++ compilation"
But I wonder what are NO_PROTOTYPE and _USING_PROTOTYPES_.
Do they refer to the prototypes put in the .h ???
Are there compilers which doesn't accept prototypes ?
How do they do, then ?
Where do I find these preprocessor on the web ? No luck on Google...
So I underdstand:
if the compiler is ANSI C and does accept prototypes, or if the compiler
is C++...
let's use prototypes !
replace _ANSI_ARGS_(x) with x
....
About VARARGS...
Why is there a condition ? I believed that, for functions with an
undetermined number of parameters, the syntax was the same in C and C++
(both use dot-dot-dot): function(parameter,...)
# define _ANSI_ARGS_(x) () ?????????
Well, if I have a prototype like
EXTERN void
surface_set_shader _ANSI_ARGS_((Surface *surface,
void *surf_desc,
Shader *shader));
I have to remplace it with
EXTERN void surface_set_shader(); ???
What about parameters ??
THANKS A LOT FOR HELP !!
Could anyone explain me the following preprocessor sentences:
----------------------------------------------------------------
#if (defined(__STDC__) && !defined(NO_PROTOTYPE)) || defined(__cplusplus)
# define _USING_PROTOTYPES_ 1
# define _ANSI_ARGS_(x) x
# define CONST const
# ifdef __cplusplus
# define VARARGS (...)
# else
# define VARARGS ()
# endif
#else
# define _ANSI_ARGS_(x) ()
# define CONST
#endif
#undef EXTERN
#ifdef __cplusplus
# define EXTERN extern "C"
#else
# define EXTERN extern
#endif
-----------------------------------------------------------------
I know that __STDC__ means: "the compiler is C compatible"
I know that __cplusplus means: "the compiler does C++ compilation"
But I wonder what are NO_PROTOTYPE and _USING_PROTOTYPES_.
Do they refer to the prototypes put in the .h ???
Are there compilers which doesn't accept prototypes ?
How do they do, then ?
Where do I find these preprocessor on the web ? No luck on Google...
So I underdstand:
if the compiler is ANSI C and does accept prototypes, or if the compiler
is C++...
let's use prototypes !
replace _ANSI_ARGS_(x) with x
....
About VARARGS...
Why is there a condition ? I believed that, for functions with an
undetermined number of parameters, the syntax was the same in C and C++
(both use dot-dot-dot): function(parameter,...)
# define _ANSI_ARGS_(x) () ?????????
Well, if I have a prototype like
EXTERN void
surface_set_shader _ANSI_ARGS_((Surface *surface,
void *surf_desc,
Shader *shader));
I have to remplace it with
EXTERN void surface_set_shader(); ???
What about parameters ??
THANKS A LOT FOR HELP !!