I have implemented a set of functions satisfying the posix interface and want to run it on my STM32 development board. However, during the compilation process, it was found that the declared structure was duplicated with the structure name in the cross-compilation toolchain. For example, they are all called pthread_attr_t
, and pthread_attr_t
in the cross-compilation toolchain is automatically used during compilation, which leads to program errors. How should I solve this problem so that my program correctly references the pthread_attr_t
I declared myself.
I can't change the name of my structure, and I also tried changing #include <face_pthread.h>
to #include "face_pthread.h"
, but it doesn't solve this problem, so I hope someone can help me.
I add a case to show my current situation.
test.h
#ifndef __TEST__
#define __TEST__
typedef unsigned char INT8U;
typedef INT8U clockid_t;
void test();
#endif
test.c
#include "test.h"
void test() {
clockid_t time;
return;
}
I compile the code with arm-none-eabi-gcc
The following is the error message
.../Test/test.h:5:15: error: conflicting types for 'clockid_t'
5 | typedef INT8U clockid_t;
|
arm-none-eabi\include\sys\types.h:199:21: note: previous declaration of 'clockid_t' was here
199 | typedef __clockid_t clockid_t;
|
Wait a minute, when I added the error case, I found that the operating system I used introduced the header file #include <stdio.h>
of the compilation toolchain in a certain configuration file, and introduced related files #include <sys/types.h>
in stdio.h
, it seems that this error is caused, maybe I need to change the question: is there any way to avoid this conflict?