lightning
[Top][All Lists]
Advanced

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

[Lightning] config.h should not be included in the library header


From: Marc Nieper-Wißkirchen
Subject: [Lightning] config.h should not be included in the library header
Date: Sun, 25 Aug 2019 10:30:20 +0200

Dear Paulo,

the first lines of <lightning.h> currently read:

**
#ifndef _lightning_h
#define _lightning_h

#if HAVE_CONFIG_H
# include "config.h"
#endif

#include <unistd.h>
#include <stdlib.h>
#if HAVE_STDINT_H
#  include <stdint.h>
#endif
#include <string.h>

#if defined(__hpux) && defined(__hppa__)
#  include <machine/param.h>
#endif
#if defined(__alpha__) && defined(__osf__)
#  include <machine/endian.h>
#endif

#ifdef STDC_HEADERS
#  include <stddef.h>
#else
#  if !defined(offsetof)
#    define offsetof(type, field) ((char *)&((type *)0)->field - (char *)0)
#  endif
#endif
**

I would like to suggest to remedy the following three things:

1) The header file should not include "config.h" (and test
HAVE_CONFIG_H) because it would include the "config.h" (and test the
preprocessor flag) of the application using GNU lightning and not the
"config.h" and the preprocessor flag of GNU lightning.

2) Likewise, the test about HAVE_STDINT_H is meaningless as long as
the program using GNU lightning does not set the appropriate
preprocessor flag.

3) A general header file should not (re-)define "offsetof". As far as
I see, it is not needed in the include file anyway.

In other words, 3) is easily corrected by moving the definition of
"offsetof" into a header file that is private to the lightning
sources.

1) and 2) can be corrected by replacing "lightning.h" by
"lightning.h.in" and using autoconf substitutions to generate a
customized "lightning.h". In the same go, one can also rewrite the
WORDSIZE tests as autoconf tests. This has also the more than welcome
side effect that "__WORDSIZE" (which should be considered private to
the compiler and standard library) doesn't need to be touched (and
redefined) by <lightning.h>.

Thanks!

Marc



reply via email to

[Prev in Thread] Current Thread [Next in Thread]