Skip to content

Commit 91b1a92

Browse files
committed
fix #439
1 parent a6d3586 commit 91b1a92

3 files changed

Lines changed: 5 additions & 3 deletions

File tree

main.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ int main(int argc, char **argv)
6060
case 's':
6161
if (std::strncmp(arg, "-std=",5)==0) {
6262
dui.std = arg + 5;
63+
dui.gnu = dui.std.rfind("gnu", 0) != std::string::npos;
6364
found = true;
6465
}
6566
break;

simplecpp.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2760,7 +2760,7 @@ static std::string extractRelativePathFromAbsolute(const std::string& absoluteSi
27602760
static std::string openHeader(std::ifstream &f, const simplecpp::DUI &dui, const std::string &sourcefile, const std::string &header, bool systemheader);
27612761
static void simplifyHasInclude(simplecpp::TokenList &expr, const simplecpp::DUI &dui)
27622762
{
2763-
if (!isCpp17OrLater(dui))
2763+
if (!isCpp17OrLater(dui) && !dui.gnu)
27642764
return;
27652765

27662766
for (simplecpp::Token *tok = expr.front(); tok; tok = tok->next) {
@@ -3483,7 +3483,7 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL
34833483
// use a dummy vector for the macros because as this is not part of the file and would add an empty entry - e.g. /usr/include/poll.h
34843484
std::vector<std::string> dummy;
34853485

3486-
const bool hasInclude = isCpp17OrLater(dui);
3486+
const bool hasInclude = isCpp17OrLater(dui) || dui.gnu;
34873487
MacroMap macros;
34883488
for (std::list<std::string>::const_iterator it = dui.defines.begin(); it != dui.defines.end(); ++it) {
34893489
const std::string &macrostr = *it;

simplecpp.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,12 +337,13 @@ namespace simplecpp {
337337
* On the command line these are configured by -D, -U, -I, --include, -std
338338
*/
339339
struct SIMPLECPP_LIB DUI {
340-
DUI() : clearIncludeCache(false), removeComments(false) {}
340+
DUI() : clearIncludeCache(false), removeComments(false), gnu(false) {}
341341
std::list<std::string> defines;
342342
std::set<std::string> undefined;
343343
std::list<std::string> includePaths;
344344
std::list<std::string> includes;
345345
std::string std;
346+
bool gnu;
346347
bool clearIncludeCache;
347348
bool removeComments; /** remove comment tokens from included files */
348349
};

0 commit comments

Comments
 (0)