Re: Using custom qualifiers like __THROW

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Snodx,

>If square_func is not valid C or C++ syntax then the same property of invalid C/C++ syntax should apply to
    extern int fcloseall(void) throw();

That is valid C++ syntax.

The "throw()" portion is a decoration on the function that tells the compiler that the function promises not throw any exceptions.  (If it were Java, it would be "...the function does not throw any throwable 'exception' hierachy objects; not counting the extraordinary throwable 'error' hierarchy.")

Please read your "The C++ Programming Language" (3rd ed. or special ed.) book from Stroustrup.

>But then
    extern int fcloseall(void) __THROW;
>does'nt seem to fit into this syntax.

In C, the code expands to...
    extern int fcloseall(void);
...which is valid C syntax as well.

>My question is according to the 'C' language valid forms of function declarations are:
    <storage-class-type> <return-type> <function-name>(<parameter type list>);

Since the macro __THROW term expands to nothing (""), the header line...
    extern int fcloseall(void) __THROW;
...expands to...
    extern int fcloseall(void);
...which is a valid form of function declarations as per C language.

System header files are at the discretion of the compiler vendor.  This particular vendor opted to instrument header file in such a way that it can be used for both C and C++ compilation.

So, what's your concern?

>If terms like __THROW are allowed then is it possible to use custom defined macros like __SNODX?

The term __THROW is a *macro*.  It expand to "throw()" in C++, and to "" (empty, no characters) in C.

No, because __SNODX is a reserved identifier.  You could use x_SNODX.

No, if you are intending to modify the macro-magic the standard headers.

Yes, if you want to use x_SNODX for your own purposes for your own functions and methods, if x_SNODX is something useful for your purposes.  For example:

#ifdef __cplusplus
#define x_SNODX throw(SnodxError)
#else
#define x_SNODX
#endif
struct SnodxError { };
void SnodFunc() x_SNODX;

HTH,
--Eljay



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux