[CMake] unable to include a source file for all sub directories

Hendrik Sattler post at hendrik-sattler.de
Fri May 15 07:33:13 EDT 2009


Zitat von ankit jain <ankitguddu at gmail.com>:
> Now all files iam getting from folder1 and folder2 and objects of all files
> including Ident.c is created... But while linking f11.obj f12.obj f21.obj
> f22.obj all show error undefined symbol:
> char *v1
>
> where Ident .c contains..
>
> char v1[]="Hello";

If you want a pointer, declare a pointer, not an array!
If you would use a common header file that is also used in  
Indent.c(!), you would get something like (I don't have MSVC at hand  
but it's also a C++ compiler):
$ cat a.c
extern char *v1;
char v1[] = "Hallo";

$ g++ -c -o a.o a.c
a.c:3: error: conflicting types for `char v1[]'
a.c:1: error: previous declaration as `char*v1'

while:
$ cat a.c
extern char *v1;
char *v1 = "Hallo";

$ g++ -c -o a.o a.c
<no errors>

HS




More information about the CMake mailing list