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

clang-format does not place file.cuh include at the top in file.cu #110532

Open
UtkarshVerma opened this issue Sep 30, 2024 · 0 comments
Open

clang-format does not place file.cuh include at the top in file.cu #110532

UtkarshVerma opened this issue Sep 30, 2024 · 0 comments

Comments

@UtkarshVerma
Copy link

Normally, whenever clang-format formats a file, it recognises the header for the current file and places it at the top. This does not work for CUDA headers and sources. Formatting works, but the header is not placed at the top.

Here are the files to reproduce, and also how they look after formatting.

util.cuh

#ifndef UTIL_CUH
#define UTIL_CUH

#include <stdbool.h>

#define CHECK(e) \
    { _check_cuda_error((e), __FILE__, __LINE__); }

void _check_cuda_error(const cudaError_t code, const char *const file,
                       const int line);

#endif  // UTIL_CUH

util.cu

#include <stdio.h>

#include "util.cuh"

void _check_cuda_error(const cudaError_t code, const char *const file,
                       const int line) {
    if (code != cudaSuccess) {
        (void)fprintf(stderr, "error: [%s:%d] %s\n", file, line,
                      cudaGetErrorString(code));
        exit(code);
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant