This is the mail archive of the libc-hacker@sources.redhat.com mailing list for the glibc project.

Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

glibc headers and C++


Hi!

glibc manual speaks about [nh]to[hn][ls] as functions, but the following
snippet which should be thus perfectly legal C++ is not compiled with -O and
higher, unless one uses (htonl) (256), because htonl is then macro expanded
into a statement expression which is not valid outside of function body.

#include <netinet/in.h>
unsigned int i = htonl (256);

I see 4 possible solutions: 
1) ifndef __cplusplus out all problematic statement expression macros in
glibc public headers
2) as 1) but add alternate definitions as inline functions for C++
3) turn stmt expression macros into inline functions for C as well (of
course, where possible)
4) hack C++ so that it accepts statement expressions in initializers (by
either turning them into some internal functions or expanding them within
__static_initializers_and_constructors or how is that function called).

What do you think?

	Jakub

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]