We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi,
I'm working on a big project with a lott of sources files. At compilation time I have a lot of #167-D warning ( warning: #167-D: argument of type "U8 *" is incompatible with parameter of type "const char *" for example ) .
Today I move some functions to another new source file to clean my code. But when I compile , I get new errors in my new source file : "error: #167: argument of type "U32 *" is incompatible with parameter of type "U8 *"
The warning in a source file becomes an error in another source file !!!
I didn't setup anything different for this source file , all compilation options are defined by the project.
What is the problem and how to solve it please ?
Previously it was a warning because although the items were of a different type they were the same size (8 bits).
Now it is an error because you are trying to pass a pointer to a 32-bit value as a parameter to a function that is expecting a pointer to an 8-bit value.
To fix the problem make sure that the size of the data that you are passing as parameters to the function matches the size of the data expected by the function.
the type pointed don't have the same size , but the pointer itself is always the same size : 32bits.
Moreover , I forgot to mention that if I cut/copy the faulty function in another source code , I get a #167-D warning and no a #167 error !!!!
Several things to think about here:
"U8*" and "const char*" can differ in two ways. One is const. One is not. You can send a non-const parameter to a function that expects a const parameter. You can not send a const parameter to a function that does not specify that it takes a const parameter. And then char can be signed or unsigned depending on compiler and optional compiler switches.
U8* and U32* is always incompatible. The "pointer" may be of the same size, but the data type the pointer points to is incompatible so a typecast is needed to convert from one pointer to the other. But to perform the type cast, YOU must know that it is correct to perform the cast.
You're right Per,
So I ask my aquestion differently :) why the same function returns me #167-D warning when its source code is in one file , and a #167 error code when the same source code is in another file ???
The settings for all the files of the project are the same.
You have to figure out why the variable was of type U8 if the function - or if it was the function call - was located in one file, and of type U32 when you moved the code to another file.
Somehow, you may have two header files that specifies different data types, or you have one header file specifying one data type, and a source file defining another data type.