Mrkol
Topic Author
Posts: 7
Joined: 23 Mar 2018, 15:07

Warning suppression

04 Apr 2018, 11:01

I'm compiling my code using clang-cl 6.0.0, and get several warnings when using NS_IMPLEMENT_INLINE_REFLECTION. Looking through noesis' headers, I figured out that there's a warning suppression mechanism, yet the NS_CLANG_WARNING_DISABLE(x) macro does basically nothing (located at CompilerSettings.h:71, according to clang). On the other hand, similar defines for MSVC and g++ actually use some compiler-specific directives and presumably do their job. Is this a bug, or a feature? Might I be doing something wrong?
 
User avatar
jsantos
Site Admin
Posts: 2900
Joined: 20 Jan 2012, 17:18
Contact:

Re: Warning suppression

04 Apr 2018, 12:32

When compiling with Visual Studio, the macro is empty
#define NS_CLANG_WARNING_DISABLE(x)
But when compiling with clang it is defined as
#define NS_CLANG_WARNING_DISABLE(x) _Pragma(NS_STRINGIFY(clang diagnostic ignored x))
I think the problem is that you are compiling using clang from Visual Studio right? So far we don't support that combination, we didn't have time to try yet. But anyways, you don't need to use our macros to suppress warnings, you can use your own ones.

What's the warning about by the way?
 
Mrkol
Topic Author
Posts: 7
Joined: 23 Mar 2018, 15:07

Re: Warning suppression

04 Apr 2018, 13:22

I am actually building from command line using cmake, nmake and clang-cl, which is a msvc-compatible clang (clang++ being g++ compatible on the other hand). Noesis 2.1.0f1 (r6972).

Here are the warnings that I get: https://pastebin.com/hKivBFnR
The first one pops up several times for each of my headers, the second one once for each one. The headers I'm talking about contain the following code:
NS_IMPLEMENT_INLINE_REFLECTION(MyWindow, NoesisApp::Window)
{
	NsMeta<Noesis::TypeId>("MyId");
}
Also, the definition changes from a stub to an actual one only if compiling with g++ (clang++ in that case), due to the following code (CompilerSettings.h:147):
    #ifdef __clang__
        #define NS_CLANG_HAS_WARNING(x) __has_warning(x)
        #define NS_CLANG_WARNING_DISABLE(x) _Pragma(NS_STRINGIFY(clang diagnostic ignored x))
    #else
        #define NS_CLANG_HAS_WARNING(x) 0
        #define NS_CLANG_WARNING_DISABLE(x)
    #endif
Whereas in the MSC branch of the if pragma the corresponding code consists of simply (CompilerSettings.h:70):
    #define NS_CLANG_HAS_WARNING(x) 0
    #define NS_CLANG_WARNING_DISABLE(x)
Replacing the latter with the former in noesis headers solves the -Winconsistent-missing-override warning, but the other one persists.
 
User avatar
jsantos
Site Admin
Posts: 2900
Joined: 20 Jan 2012, 17:18
Contact:

Re: Warning suppression

05 Apr 2018, 09:35

Thanks for the details. For now I recommend including Noesis from a single header (you can use the provided PCH header for that) and silence all the warnings using standard mechanisms (not using Noesis macros, they are there for internal usage).

Once we have time to properly support clang in Visual Studio we will address all these problems. We care about having no warnings when our code is compiled by clients.

Who is online

Users browsing this forum: No registered users and 0 guests