Discussion:
#ifndef BIGENDIAN #undef BIGENDIAN ?
Kai Noda
2017-02-26 07:10:35 UTC
Permalink
Hi all,

I don't quite understand this piece of code:

http://git.savannah.gnu.org/gitweb/?p=autoconf.git;a=blobdiff;f=lib/autoconf/c.m4;h=51fdfeba68fffe7f6f5638eaeef00149ed168282;hp=ffaa06e39dff758a24618a8f6504b22103caefac;hb=b0e687ef42e21b1eb7af18c4eaebcd41b0bd5632;hpb=883c8994f1efdc3c550b0d37bf95c947881b735d

#else
# ifndef WORDS_BIGENDIAN
# undef WORDS_BIGENDIAN
# endif

What was it supposed to achieve? Should it not be either of these two?

#ifndef WORDS_BIGENDIAN
**#define** WORDS_BIGENDIAN

or

**#ifdef** WORDS_BIGENDIAN
#undef WORDS_BIGENDIAN

Please disregard if I missed something elementary. I'm not literate in m4.
I just tried to use AC_C_BIGENDIAN for my project and was startled to
see its output.

Regards,
Kai

野田 開 <***@gmail.com>
Eric Blake
2017-02-27 15:56:48 UTC
Permalink
Post by Kai Noda
Hi all,
http://git.savannah.gnu.org/gitweb/?p=autoconf.git;a=blobdiff;f=lib/autoconf/c.m4;h=51fdfeba68fffe7f6f5638eaeef00149ed168282;hp=ffaa06e39dff758a24618a8f6504b22103caefac;hb=b0e687ef42e21b1eb7af18c4eaebcd41b0bd5632;hpb=883c8994f1efdc3c550b0d37bf95c947881b735d
#else
# ifndef WORDS_BIGENDIAN
# undef WORDS_BIGENDIAN
# endif
This is the proper way to set up a config template. When config.status
runs, ALL it does is replace '#undef' lines with either '/* #undef */'
or '#define' lines, according to what was learned during configure. All
other lines are left untouched.
Post by Kai Noda
What was it supposed to achieve? Should it not be either of these two?
#ifndef WORDS_BIGENDIAN
**#define** WORDS_BIGENDIAN
This is what results in the final config.h based on the template on
machines where the #define is needed.
Post by Kai Noda
or
**#ifdef** WORDS_BIGENDIAN
#undef WORDS_BIGENDIAN
No, this is not what is wanted.
Post by Kai Noda
Please disregard if I missed something elementary. I'm not literate in m4.
It's not m4, but autoconf doing this. It's documented here:
https://www.gnu.org/software/autoconf/manual/autoconf.html#Header-Templates
Post by Kai Noda
I just tried to use AC_C_BIGENDIAN for my project and was startled to
see its output.
The output is correct. Remember that config.h.in files have a slightly
different syntax than the final generated config.h file.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
Loading...