Skip to content

Including what you use is find, but not without inclusion guards #251

@HBBroeker

Description

@HBBroeker

As of quite recently (likely commit 3e0e62c), re2c fails to build here, because of a multiple definition error in src/parse:

make: Entering directory '/home/hbbro/src/re2c/bld/cyg/gcc'
make  all-am
make[1]: Entering directory '/home/hbbro/src/re2c/bld/cyg/gcc'
  CXX      src/parse/lex.o
In file included from ../../../re2c/src/parse/scanner.h:12:0,
                 from ../../../re2c/src/parse/lex.re:18:
./src/parse/lex.h:12:8: error: redefinition of 'struct re2c::ScannerState'
 struct ScannerState
        ^~~~~~~~~~~~
In file included from ../../../re2c/src/parse/lex.re:17:0:
./src/parse/lex.h:12:8: note: previous definition of 'struct re2c::ScannerState'
 struct ScannerState
        ^~~~~~~~~~~~
make[1]: *** [Makefile:2045: src/parse/lex.o] Error 1
make[1]: Leaving directory '/home/hbbro/src/re2c/bld/cyg/gcc'
make: *** [Makefile:1233: all] Error 2
make: Leaving directory '/home/hbbro/src/re2c/bld/cyg/gcc'

Including headers that define stuff used by a given header is a good approach. But it cannot really work if the headers do not have multiple-inclusion guards, i.e. like this:

#ifndef RE2C_INCLUDED_LEX_H
#define RE2C_INCLUDED_LEX_H
// alll the contents in here ...
#endif /* RE2C_INCLUDED_LEX_H */

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions