D
David Sudolcan
I can't figure out why PC-Lint complains about the following code.
Can you help? I have the following code in a header file.
#ifndef _THIS_HEADER_FILE
#define _THIS_HEADER_FILE
typedef enum
{
RESULT_ERROR = -1,
RESULT_PASS = 0,
RESULT_BUSY = 1,
RESULT_FAIL = 2
}result_t;
#endif
And I have a different header file that has this in it.
#ifndef _THAT_HEADER_FILE
#define _THAT_HEADER_FILE
typedef struct
{
result_t (*function1)(void);
result_t (*function2)(int);
}interface_t;
#endif
And I have a source file that includes the above header files (first
'this', then 'that'), and PC-Lint complains about the lines in the 2nd
header file, as shown below.
typedef struct
{
result_t (*function1)(void); <-- message 145 = type expected before
operator, void assumed
result_t (*function2)(int); <-- message 145 = type expected before
operator, void assumed
}interface_t;
If I change the return type of function1 and function2 to int, the
problem goes away.
If I change the name of the typedef in the 1st header file, both GCC
and PC-Lint complain that they don't know what result_t is anymore.
If I move the result_t definition to the 2nd header file, the problem
goes away (but that breaks the design, because I need to include both
the result_t and the interface_t in several other source files.
GCC doesn't complain about the code, and it seems to work just fine.
I'm trying to make a structure that's an interface to something, where
the interface functions return a predefined type (things like busy,
pass, fail, error, etc.).
Is there something wrong with the way I'm trying to make this work?
Shouldn't PC-Lint know that that result_t is a valid type because the
1st header file is always included before the 2nd one is included?
I'm confused... help... please.
Can you help? I have the following code in a header file.
#ifndef _THIS_HEADER_FILE
#define _THIS_HEADER_FILE
typedef enum
{
RESULT_ERROR = -1,
RESULT_PASS = 0,
RESULT_BUSY = 1,
RESULT_FAIL = 2
}result_t;
#endif
And I have a different header file that has this in it.
#ifndef _THAT_HEADER_FILE
#define _THAT_HEADER_FILE
typedef struct
{
result_t (*function1)(void);
result_t (*function2)(int);
}interface_t;
#endif
And I have a source file that includes the above header files (first
'this', then 'that'), and PC-Lint complains about the lines in the 2nd
header file, as shown below.
typedef struct
{
result_t (*function1)(void); <-- message 145 = type expected before
operator, void assumed
result_t (*function2)(int); <-- message 145 = type expected before
operator, void assumed
}interface_t;
If I change the return type of function1 and function2 to int, the
problem goes away.
If I change the name of the typedef in the 1st header file, both GCC
and PC-Lint complain that they don't know what result_t is anymore.
If I move the result_t definition to the 2nd header file, the problem
goes away (but that breaks the design, because I need to include both
the result_t and the interface_t in several other source files.
GCC doesn't complain about the code, and it seems to work just fine.
I'm trying to make a structure that's an interface to something, where
the interface functions return a predefined type (things like busy,
pass, fail, error, etc.).
Is there something wrong with the way I'm trying to make this work?
Shouldn't PC-Lint know that that result_t is a valid type because the
1st header file is always included before the 2nd one is included?
I'm confused... help... please.