Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions source/dpp/runtime/options.d
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ struct Options {
bool hardFail;
bool cppStdLib;
bool ignoreMacros;
string[] ignoredMacros;
bool detailedUntranslatable;
string[] ignoredNamespaces;
string[] ignoredCursors;
Expand Down Expand Up @@ -125,6 +126,7 @@ struct Options {
"hard-fail", "Translate nothing if any part fails", &hardFail,
"c++-std-lib", "Link to the C++ standard library", &cppStdLib,
"ignore-macros", "Ignore preprocessor macros", &ignoreMacros,
"ignore-specified-macros", "Ignore the specified preprocessor macros", &ignoredMacros,
"ignore-ns", "Ignore a C++ namespace", &ignoredNamespaces,
"ignore-cursor", "Ignore a C++ cursor", &ignoredCursors,
"ignore-path", "Ignore a file path, note it globs so you will want to use *", &ignoredPaths,
Expand All @@ -146,6 +148,7 @@ struct Options {
);

clangOptions = map!(e => e.split(" "))(clangOptions).join();
ignoredMacros = map!(e => e.split(","))(ignoredMacros).join();

if(helpInfo.helpWanted) {
() @trusted {
Expand Down
3 changes: 2 additions & 1 deletion source/dpp/translation/macro_.d
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ string[] translateMacro(in from!"clang".Cursor cursor,

// we want non-built-in macro definitions to be defined and then preprocessed
// again

if(isBuiltinMacro(cursor)) return [];

if (context.options.ignoredMacros.canFind(cursor.spelling)) return [];

const tokens = cursor.tokens;

// the only sane way for us to be able to see a macro definition
Expand Down