N
nrhayyal
Hi c++ Gurus,
Need your blessing.
while testing few aspects with respect to header file inclusions, i
observed few things which i would like to share with you.
i have a file sqlca.h in which a structure sqlca is declared.
i included this file as a soft link in /usr/include.
the soft link is as follows:
sqlca.h -> /usr/opt/db2_08_01/include64/sqlca.h
then i wrote a small program as below:
//test1.cpp
#include<iostream.h>
#include<sqlca.h> // normal inclusion
#include<sqlca.h> // testing for duplicate
int main()
{
return 0;
}
with this kind of inclusion , i didnt get any warnings/errors.
But if i included this file as a soft link in myproject/src/include
and changed the code as shown below:
//test2.cpp
#include<iostream.h>
#include "sqlca.h" // normal inclusion
#include "sqlca.h" // testing for duplicate
int main()
{
return 0;
}
this gives me a error saying redeclaration of "struct sqlca" in
test2.cpp at 4 line
previously declared in
test2.cpp at 3 line
But the same doesnt throw any error if i create a soft link in
/usr/include.
i am using gcc compiler gcc3.3.2
why is it that :
if we include "/usr/include/sqlca.h" twice in our program doesnt throw
any error message,
where as if we include "myproject/src/include/sqlca.h" throws error.
how the compiler interpretes header files of standard header and normal
headers.
please help me in understanding this.
Thanks & regards
Nagaraj Hayyal
mobile:+919885534944
Need your blessing.
while testing few aspects with respect to header file inclusions, i
observed few things which i would like to share with you.
i have a file sqlca.h in which a structure sqlca is declared.
i included this file as a soft link in /usr/include.
the soft link is as follows:
sqlca.h -> /usr/opt/db2_08_01/include64/sqlca.h
then i wrote a small program as below:
//test1.cpp
#include<iostream.h>
#include<sqlca.h> // normal inclusion
#include<sqlca.h> // testing for duplicate
int main()
{
return 0;
}
with this kind of inclusion , i didnt get any warnings/errors.
But if i included this file as a soft link in myproject/src/include
and changed the code as shown below:
//test2.cpp
#include<iostream.h>
#include "sqlca.h" // normal inclusion
#include "sqlca.h" // testing for duplicate
int main()
{
return 0;
}
this gives me a error saying redeclaration of "struct sqlca" in
test2.cpp at 4 line
previously declared in
test2.cpp at 3 line
But the same doesnt throw any error if i create a soft link in
/usr/include.
i am using gcc compiler gcc3.3.2
why is it that :
if we include "/usr/include/sqlca.h" twice in our program doesnt throw
any error message,
where as if we include "myproject/src/include/sqlca.h" throws error.
how the compiler interpretes header files of standard header and normal
headers.
please help me in understanding this.
Thanks & regards
Nagaraj Hayyal
mobile:+919885534944