A syntax check problem of Clion

Answered

I have a cpp file includes a header file "A.h", and A.h contains following code:

#pragma once

#include "B.h"

struct test

{

     int x;

};

 

and B.h contains following code:

#pragma once

#include "A.h"

 

then, Clion will generate an error that struct "test" is redefinition in "A.h", but gcc 11 builds ok.

and, if I replace #pragma once with tranditional "#ifndef __XXX_H__ #define __XXX_H__ #endif", clion will not generate any error.

 

I think this may be a clion bug that analyzed file(especially header file) isn't regard as a part of "#pragma once"

 

Please sign in to leave a comment.