Hi,
I am using TMS320F28335 Controller and CCS V3.3 studio. I faced strange issue. I defined a variable in one file and I used the same in other file with slight modifications in prototype.
Still code got compiled, without any linking error. Below is the example.
Example for No Error or Warning code
I did not get any compiler/linker error.
In file1. c I defined 16-bit unsigned global variable as follows.
UINT16 gu16GlobalIndex = NULL;
In file2.c I am using this variable. Below is the declaration of the variable. Here I gave ‘UINT32’ instead of ‘UINT16’
extern UINT32 gu16GlobalIndex;
//Use gu16GlobalIndex;
Example for Error code
I tried to move the declaration to file1.h and include this file in file2.c as show below. Now it gives the error.
In file1.h I declared this variable with change in prototype. Here I gave ‘UINT32’ instead of ‘UINT16’
In file2.c I am using this variable by including file1.h.
#include “file1.h”
My query is both approach are same. But how come in one approach there is no error, where as in other approach, there is an error.
Thanks & Regards
Vishnu Beema
Please see http://c-faq.com/decl/decldef.html .
Thanks and regards,
-George
TI C/C++ Compiler Forum ModeratorPlease click Verify Answer on the best reply to your question.The Compiler Wiki answers most common questions.Track an issue with SDOWP. Enter your bug id in the "Find Record ID" box.