| Topic: |
DEVELOP > c-Plus-Plus |
| User: |
"Frederick Reeve" |
| Date: |
19 Nov 2003 09:09:51 PM |
| Object: |
Complation problem involving namespaces. |
Hey all I have a little compilation problem I think is related to name
spaces but being new to C++ still I don't know the program
(http://rafb.net/paste/results/f1416037.html) when it is being linked
returns with "undefined reference to foo" for function in a C lib i have
linked... any Ideas?
I am attempting to link a C lib and I think the complication comes in here
also.
If it would be better I can post the program in another message. Its only
153 lines. The program in the opening comments includes the command I use
to compile this and the c version of it. The C version compiles fine by
the way.
Thanks for being there guys.
--
Want to email me? remove both dashes from the email address.
.
|
|
| User: "Ivan Vecerina" |
|
| Title: Re: Complation problem involving namespaces. |
20 Nov 2003 01:03:24 AM |
|
|
"Frederick Reeve" <fred-e-rick@woodland-i.org> wrote in message
news:pan.2003.11.20.03.09.50.436285@woodland-i.org...
| Hey all I have a little compilation problem I think is related to name
| spaces but being new to C++ still I don't know the program
| (http://rafb.net/paste/results/f1416037.html) when it is being linked
| returns with "undefined reference to foo" for function in a C lib i have
| linked... any Ideas?
|
| I am attempting to link a C lib and I think the complication comes in here
| also.
.....
| The C version compiles fine by the way.
To include C headers from a C++ program, you need to place them
within an extern "C" block:
extern "C" {
#include <SomeCHeader.h>
}
This is because the C++ compiler uses name mangling (encoding the type
of the parameters into the link name of a function) to allow function
overloading. This mangling is disabled within the extern "C" block...
Cheers,
Ivan
--
http://ivan.vecerina.com
.
|
|
|
| User: "Frederick Reeve" |
|
| Title: Re: Complation problem involving namespaces. |
20 Nov 2003 07:09:41 PM |
|
|
To include C headers from a C++ program, you need to place them
within an extern "C" block:
extern "C" {
#include <SomeCHeader.h>
}
This is because the C++ compiler uses name mangling (encoding the type
of the parameters into the link name of a function) to allow function
overloading. This mangling is disabled within the extern "C" block...
Thanks a lot Ivan That took care of the problem.
Frederick.
--
Want to email me? remove both dashes from the email address.
.
|
|
|
|
|

|
Related Articles |
|
|