Superbelko / ohmygentool

LLVM/Clang based bindings generator for D language
The Unlicense
39 stars 6 forks source link

Error when generating enums #9

Closed Imperatorn closed 3 years ago

Imperatorn commented 3 years ago

When generating enums, there's a small issue if the character used is backtick, since it's used for the value.

enum ACS_DIAMOND = PDC_ACS('')` <--This would not be handled properly. You would get "unterminated character constant"

Superbelko commented 3 years ago

In C++ or in D? Sorry I don't get it, formatting destroyed it. Can you attach screenshot of what the source and the result?

edit: I think I get it, after searching on github it seems related to ncurses lib and terminals, where it is defined as a macro, so that wasn't actually a string literal or enum.

Superbelko commented 3 years ago

Minimal repro case

#define NOOP(a) a
#define BUG NOOP('`')

result

enum NOOP(a) = `a`;
enum BUG = `NOOP('`')`;
Imperatorn commented 3 years ago

Minimal repro case

#define NOOP(a) a
#define BUG NOOP('`')

result

enum NOOP(a) = `a`;
enum BUG = `NOOP('`')`;

Correct :)