This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: quick question
>>>>> "Martin" == Martin von Loewis <martin@mira.isdn.cs.tu-berlin.de> writes:
>> When I used gcc to compile my codes, I found that the compiler didn't examine
>> all my codes. It seemed that it only check those functions in classes which
>> I actually used in an application.
FMartin> No, the compiler examines all source code it compiles. Can you provide
FMartin> a specific example?
FMartin> Martin
Here is a simple piece of code:
template <class T>
void test1(T v1, T v2)
{
v = v1;
}
int main(int, char**)
{
float a;
a = 0.1f;
test1(a, 0.1f);
return (0);
}
You notice the variable v in the template function test1() is undeclared. In the
main() function, if I comment out the line calling test1(), the compiler gives
no complains and generate an executable. If we include the line, then the
compiler is able to pick out the error:
test.cpp: In function `void test1(float, float)':
test.cpp:4: `v' undeclared (first use this function)
test.cpp:4: (Each undeclared identifier is reported only once
test.cpp:4: for each function it appears in.)
Is there an option which I can use to force the compiler to examine all the
codes?
--
Xiaomao
=================================================================
Xiaomao (Mark) Xiao E-Mail: xiao@cmold.com
C-MOLD TEL: (607) 257-4949 x 699
31 Dutch Mill Road FAX: (607) 257-6355
Ithaca, NY 14850 URL: http://www.cmold.com
=================================================================