mangled functions 
Author Message
 mangled functions

I need help. I have tried to think over this problem for a couple of days
put no solution yet. New in programming in C. My functions are being
mangleed y c++.
when it links geives me error no function defined. Yes I did try to use
extern "C" around mu function prototype but it dind it help. Error is
undefined _"function" in module "filename".
please help.



Fri, 07 Jan 2000 03:00:00 GMT  
 mangled functions



Quote:
>I need help. I have tried to think over this problem for a couple of days
>put no solution yet. New in programming in C. My functions are being
>mangleed y c++.

If you are programming in C you must use a C compiler, not a C++ compiler.
C and C++ are different languages.

Quote:
>when it links geives me error no function defined. Yes I did try to use
>extern "C" around mu function prototype but it dind it help. Error is
>undefined _"function" in module "filename".

If you genuinely have a problem with C post some code so we can see what
you are doing.

--
-----------------------------------------


-----------------------------------------



Fri, 07 Jan 2000 03:00:00 GMT  
 mangled functions



Quote:
>I need help. I have tried to think over this problem for a couple of days
>put no solution yet. New in programming in C. My functions are being
>mangleed y c++.
>when it links geives me error no function defined. Yes I did try to use
>extern "C" around mu function prototype but it dind it help. Error is
>undefined _"function" in module "filename".

My *guess* is that the function declarations are inconsistent.
C++ implementations typically embed the interface types in the function
name so the linker can handle distinct functions with "the same name".

In C programming, one good technique is to create a header (.h)
file that declares every function you provide with external linkage,
and #include that header in your real (.c) source files to ensure
that the function is declared identically everywhere.  (Even in the
file that defines its content.)



Sat, 08 Jan 2000 03:00:00 GMT  
 mangled functions


Quote:

>I need help. I have tried to think over this problem for a couple of days
>put no solution yet. New in programming in C. My functions are being
>mangleed y c++.

Common sense would have it that one should use a C compiler for compiling C
programs and a C++ compiler for compiling C++ programs.

Previously translated units of C programs may be linked against C++
translation units. You have to ensure that the C++ translation units include
declarations for external objects and functions that are located in
the C translation units, and that these are placed in    extern "C" { }
declaration environments. The usual thing to do is to place these declarations
into a header file, and use the preprocessor to select C or C++:

        /*
         * Header file for C module
         */

        #ifdef __cplusplus
        extern "C" {
        #endif

        /* C declarations are put here  */

        #ifdef __cplusplus
        }
        #endif

Of course, you must still be careful in the C declarations. For example, you
may not use C++ keywords for your identifiers. And the use of __cplusplus means
that it's no longer strict ANSI C, because ANSI C reserves such identifiers for
use by the implementation. For example, an ANSI C compiler could predefine a
macro called __cplusplus, in which case you would get a syntax error.

Quote:
>when it links geives me error no function defined. Yes I did try to use
>extern "C" around mu function prototype but it dind it help. Error is
>undefined _"function" in module "filename".
>please help.

Sounds like your C and C++ compilers are incompatible, in that one of them
expects plain C symbols to be stored in the object file with a leading
underscore, and the other one does not. Ooops!

Since your problem has little to do with C as an abstract programming language,
please consult a newsgroup that discusses the implementation-specific details
of your compilers.



Sat, 08 Jan 2000 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Function for mangling

2. Threaded function mangles CString members?

3. Threaded function mangles CString members?

4. name mangling

5. Name mangling problem

6. Question about name-mangling and C lib files.

7. Template name-mangling bug

8. Library Symbols Mangled

9. Name Mangling in Microsoft Visual C++

10. qsort mangling again

11. qsort mangling

12. Good ways to obfuscate/mangle strings?

 

 
Powered by phpBB® Forum Software