R
Rahul
Hi,
Everyone i get the following error when i compile and link both of
the files,
: undefined reference to `a'
a.c
#include <cstdio>
const int a = 6;
extern int fun();
int main()
{
printf("a in a is %d",a);
fun();
return ( 0 ) ;
}
b.c
# include <cstdio>
extern const int;
int fun()
{
printf("a in b.c is %d\n",a);
return ( 0 ) ;
}
However it works fine for the following cases, ( which i feel doesn't
make sense, as a new value could be set to the constant varialbe)
a.c
#include <cstdio>
const int a = 6;
extern int fun();
int main()
{
printf("a in a is %d",a);
fun();
return ( 0 ) ;
}
b.c
# include <cstdio>
extern const int a = 7;
int fun()
{
printf("a in b.c is %d\n",a);
return ( 0 ) ;
}
Thanks in advance!!!
Everyone i get the following error when i compile and link both of
the files,
: undefined reference to `a'
a.c
#include <cstdio>
const int a = 6;
extern int fun();
int main()
{
printf("a in a is %d",a);
fun();
return ( 0 ) ;
}
b.c
# include <cstdio>
extern const int;
int fun()
{
printf("a in b.c is %d\n",a);
return ( 0 ) ;
}
However it works fine for the following cases, ( which i feel doesn't
make sense, as a new value could be set to the constant varialbe)
a.c
#include <cstdio>
const int a = 6;
extern int fun();
int main()
{
printf("a in a is %d",a);
fun();
return ( 0 ) ;
}
b.c
# include <cstdio>
extern const int a = 7;
int fun()
{
printf("a in b.c is %d\n",a);
return ( 0 ) ;
}
Thanks in advance!!!