Complation problem involving namespaces.



 DEVELOP > c-Plus-Plus > Complation problem involving namespaces.

LINK TO THIS PAGE  


rating :  0   |  0


  Page 1 of 1

1

 
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.
.



  Page 1 of 1

1

 


Related Articles
 

NEWER

pg.1232     pg.940     pg.716     pg.544     pg.412     pg.311     pg.234     pg.175     pg.130     pg.96     pg.70     pg.50     pg.35     pg.24     pg.16     pg.10     pg.6     pg.3     pg.1

OLDER