Skip to content

Conflicting enum and #define identifiers make a translated header cause invalid redefinition of constant #467

Open
@topolarity

Description

@topolarity

NgSpice has a habit of establishing most enum-like constants with #define: https://github.com/imr/ngspice/blob/902a62d2f442a1d8322ae4fcad35c143c7a14561/src/include/ngspice/noisedef.h#L72-L74

but then occasionally introducing an enum { ... } with the same names wrapped in an ifdef guard: https://github.com/imr/ngspice/blob/902a62d2f442a1d8322ae4fcad35c143c7a14561/src/include/ngspice/acdefs.h#L29-L35

Example:

// test1.h
#ifndef TEST_H_
#define TEST_H_
enum {
    DECADE = 1,
    OCTAVE,
    LINEAR,
};
#endif // TEST_H_
// test2.h
#ifndef TEST_H_
#define DECADE 1
#endif

result:

module TestModule

const __JL_Ctag_1 = UInt32
const DECADE = 1 % UInt32
const OCTAVE = 2 % UInt32
const LINEAR = 3 % UInt32

const DECADE = 1
# ...
end # module

It would be nice if Clang.jl either:

  • Applied the #define across header files so that the duplicate enum definition is not parsed, OR
  • Merged the enum and #define constants, since their definitions are compatible up to a difference of integer type

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions