-Winfinite-recursion when #define NOB_STRIP_PRIFIX from multiple locations · Issue #65 · tsoding/nob.h · GitHub
More Web Proxy on the site http://driver.im/
You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using nob.h both as a build tool and as a library in my program. It's small and I find all the macros immensely useful to have at hand. As a library, I include it from two places: once in the header file because I'm using {Nob,}String_Builder and once in the .c file. I only declare #define NOB_IMPLEMENTATION once, in the .c file. Even so, I get this -Winfinite-recursion warning, which is kind of cool.
(library U:2 ?:4 ✗) wdc cc -Wall -Wextra -o build/wdc src/wdc.c src/main.cIn file included from src/wdc.c:12:src/nob.h:1562:36: warning: result of comparison of constant 0 with expression of type 'bool' is always false [-Wtautological-constant-compare] 1562 | if (rename(old_path, new_path) < 0) { | ~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~src/nob.h:1554:1: warning: all paths through this function will call itself [-Winfinite-recursion] 1554 | { | ^2 warnings generated.
I'm not using NOB_GO_REBUILD_URSELF in my lib yet. And this is just a warning. I could be doing something wrong. My C is a little rusty. The answer might just be, "don't do that." But, like you, I'm trying to always compile with -Wall and -Wextra, so I thought you might want to know about a case where a warning is generated.
This is probably due to the fact that rename is actually a libc function, which is probably the intended use here. But, if/when NOB_STRIP_PREFIX is defined it's becoming the same function as nob_rename. For now, I just stopped using NOB_STRIP_PREFIX entirely to avoid the warning. That way, it probably avoids any actual possible infinite recursion, too.
The text was updated successfully, but these errors were encountered:
I'm using nob.h both as a build tool and as a library in my program. It's small and I find all the macros immensely useful to have at hand. As a library, I include it from two places: once in the header file because I'm using
{Nob,}String_Builder
and once in the.c
file. I only declare#define NOB_IMPLEMENTATION
once, in the.c
file. Even so, I get this-Winfinite-recursion
warning, which is kind of cool.I'm not using NOB_GO_REBUILD_URSELF in my lib yet. And this is just a warning. I could be doing something wrong. My C is a little rusty. The answer might just be, "don't do that." But, like you, I'm trying to always compile with
-Wall
and-Wextra
, so I thought you might want to know about a case where a warning is generated.This is probably due to the fact that
rename
is actually a libc function, which is probably the intended use here. But, if/when NOB_STRIP_PREFIX is defined it's becoming the same function asnob_rename
. For now, I just stopped using NOB_STRIP_PREFIX entirely to avoid the warning. That way, it probably avoids any actual possible infinite recursion, too.The text was updated successfully, but these errors were encountered: