Re: g++ compile warning: extra tokens at end of #include directive

From: Mike Hewson (hewsmike_at_optusnet.com.au)
Date: 01/07/05


Date: Fri, 07 Jan 2005 19:03:11 +1100

japh wrote:
> I just started learning c++ and am at the point of using:
>
> #include "myclass.cpp"
>
> instead of having the class definition in the main file. But I am
> getting this warning at compile time:
>
> cat.cpp:4:19: warning: extra tokens at end of #include directive
>
> The program compiles and runs fine, but the warning is puzzling and
> concerns me. A google search returned lots of matches but no
> solutions...
>
> Any ideas? thanks

You'd put the interface/declarations in say "myclass.h" and include
that. The definitions are in "myclass.cpp" and get added to your compile
( and link ) list for the project.

<aside>

ISO/IEC 14882:1998(E) © ISO/IEC
16.2 Source file inclusion
.
.
5 The mapping between the delimited sequence and the external source
file name is implementation defined. The implementation provides unique
mappings for sequences consisting of one or more nondigits (2.10)
followed by a period (.) and a single nondigit. The implementation may
ignore the distinctions of alphabetical case.

<end aside>

-- 
Cheers
-- 
Hewson::Mike
"This letter is longer than usual because I lack the time to make it
shorter" - Blaise Pascal


Relevant Pages

  • Re: VB Compiler Warnings & other woes ...
    ... you will get this warning in vs 2005. ... > have a direct legacy language path of evolution to consider. ... >> compile time errors rather than runtime. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: GNAT wont link on "warning"
    ... The reason it won't compile is that you caused the constraint ... This is an error and not a warning. ... When runtime constraint errors are detected at compile time, ...
    (comp.lang.ada)
  • g++ compile warning: extra tokens at end of #include directive
    ... I just started learning c++ and am at the point of using: ... instead of having the class definition in the main file. ... getting this warning at compile time: ...
    (comp.lang.cpp)
  • Re: [coding practises] do you declare your superclass "throws"??
    ... It could stand to give a warning in this case, or where it's final or private. ... and then having to also comment out the try-catch. ... Java's philosophy tends to be to check as much as can be checked at compile time. ...
    (comp.lang.java.programmer)
  • Re: Annoying 1.5 warnings
    ... To understand the warning, you need to understand how generics work. ... While at compile time generic types are full, ...
    (comp.lang.java.programmer)