By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,276 Members | 2,063 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,276 IT Pros & Developers. It's quick & easy.

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

P: n/a
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

Jul 22 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
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
Jul 22 '05 #2

P: n/a
Yeah - I guess I wasn't precise in describing the problem. I do have a
header file, etc. The problem seems to be with including files.
#include <iostream> works fine.

#include "myheader.hpp"; yields a warning but still works.
I'm using g++ on FreeBSD

Thanks

Jul 22 '05 #3

P: n/a
DOH -- pretty simple error:

I was typing
#include "myclass.hpp";

instead of
#include "myclass.hpp"

It turns out the semi-colon was the problem.

Jul 22 '05 #4

P: n/a
japh wrote:
It turns out the semi-colon was the problem.


They're over-rated. Semi-colons are all just half-arsed. :-)

--

Cheers
--
Hewson::Mike
"This letter is longer than usual because I lack the time to make it
shorter" - Blaise Pascal
Jul 22 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.