Q
qingning
Hi,
I've encountered code declaring functions with "const int" as parameter
type, but use "int" when defining the function. This worked fine with
g++, but failed at linking time with Sun CC. The following is an
example.
--cut--
$ cat constf.h
void f(const int);
$ cat constf.cc
#include "constf.h"
void f(int)
{
}
$ cat mconstf.cc
#include "constf.h"
int main()
{
f(0);
}
$ CC constf.cc mconstf.cc
constf.cc:
mconstf.cc:
Undefined first referenced
symbol in file
void f(const int) mconstf.o
ld: fatal: Symbol referencing errors. No output written to a.out
$ CC -V
CC: Sun C++ 5.8 2005/10/13
--cut--
Is this valid c++ code? If I put everything to a single source file, CC
compiles and links fine. I am wondering whether Sun CC linker is at
fault.
--cut--
$ cat constf2.cc
void f(const int);
void f(int)
{
}
int main()
{
f(0);
}
$ CC constf2.cc
$
--cut--
Thanks for help.
qingning
I've encountered code declaring functions with "const int" as parameter
type, but use "int" when defining the function. This worked fine with
g++, but failed at linking time with Sun CC. The following is an
example.
--cut--
$ cat constf.h
void f(const int);
$ cat constf.cc
#include "constf.h"
void f(int)
{
}
$ cat mconstf.cc
#include "constf.h"
int main()
{
f(0);
}
$ CC constf.cc mconstf.cc
constf.cc:
mconstf.cc:
Undefined first referenced
symbol in file
void f(const int) mconstf.o
ld: fatal: Symbol referencing errors. No output written to a.out
$ CC -V
CC: Sun C++ 5.8 2005/10/13
--cut--
Is this valid c++ code? If I put everything to a single source file, CC
compiles and links fine. I am wondering whether Sun CC linker is at
fault.
--cut--
$ cat constf2.cc
void f(const int);
void f(int)
{
}
int main()
{
f(0);
}
$ CC constf2.cc
$
--cut--
Thanks for help.
qingning