Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider using pragmas to always mark nvtx headers as system headers and silence warnings #109

Open
jrhemstad opened this issue Dec 18, 2024 · 0 comments

Comments

@jrhemstad
Copy link
Contributor

One of the differences between using -I vs -isystem is that headers found through -isystem will not emit warnings in user code. This is convenient when user code compiles with stricter warnings that might trigger a warning in nvtx header code, but it requires users to know to use -isystem (or a cmake SYSTEM include).

A more robust option that doesn't require people to know the difference between -I and -isystem is to use #pragma system_header on the top of every NVTX header to automatically make it as if the header were found via -isystem and silence any warnings.

For context, we did the same thing with CCCL headers here: NVIDIA/cccl#527

This would look something like:

// Check for GCC (probably needs version checks)
#if defined(__GNUC__) && !defined(__clang__)
    #define NVTX3_IMPLICIT_SYSTEM_HEADER _Pragma("GCC system_header")

// Check for Clang (probably needs version checks)
#elif defined(__clang__) 
    #define NVTX3_IMPLICIT_SYSTEM_HEADER _Pragma("clang system_header")

// Check for MSVC (probably needs version checks)
#elif defined(_MSC_VER) 
    #define NVTX3_IMPLICIT_SYSTEM_HEADER __pragma(system_header)

// If none of the known compilers are detected, define it as an empty statement
#else
    #define NVTX3_IMPLICIT_SYSTEM_HEADER
#endif

// If the disable flag is set, define it as an empty statement
#else
    #define NVTX3_IMPLICIT_SYSTEM_HEADER
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant