switchbrew / libnx

Library for Switch Homebrew

Home Page:https://switchbrew.github.io/libnx/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Compiler warning after simply #including <switch.h>

jpjokela opened this issue · comments

commented

Using my own Makefile with some required modifications for switch, and here's the problem:
including <switch.h> includes "switch/services/audren.h", which has line
"#if __cplusplus >= 201402L". __cplusplus is completely undefined in my C code.

That becomes a warning (which becomes build breaking error, with any sensible build switches)

Perhaps there should be #ifdef __cplusplus around it?

commented

This is not an issue at all in any of the C-only projects that are built with libnx. Can you post your makefile? If it's a Switch-exclusive project, you should use the project template we provide instead of trying to come up with your own makefile.

commented

Addendum: C standard says that undefined identifiers in #if expressions evaluate to zero. So the #if-section in audren.h is legal and well formed.

commented

In the end, this is caused by -Wundef warning flag (and -Werror obviously)

As a workaround, adding -Wno-error=undef to the switch specific compile flags works.