473,811 Members | 3,532 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Name Mangling in DDK

Hi,
I was trying to call a function in an an asm file from a C
file(driver).

In c file the funcrtion is defined as:
extern int foo(int,int);
In the asm file the function is defined as _foo.

when I link the 2 binaries in VC++ it works fine but with DDK this
gives as error saying _foo@8 not found.

Is there a way to do away with this name mangling.
Since this driver is to be used on both 32 and 64 bit platforms I dont
want the number changing from one version to another.

Thankx a zillion.
Sunil.

Jul 22 '05 #1
4 1890
sunny posted:
Hi,
I was trying to call a function in an an asm file from a C
file(driver).

In c file the funcrtion is defined as:
extern int foo(int,int);
In the asm file the function is defined as _foo.

when I link the 2 binaries in VC++ it works fine but with DDK this
gives as error saying _foo@8 not found.

Is there a way to do away with this name mangling.
Since this driver is to be used on both 32 and 64 bit platforms I dont
want the number changing from one version to another.

Thankx a zillion.
Sunil.


comp.lang.c
As for C++,

extern "C" int foo(int,int);
-JKop

Jul 22 '05 #2
On Fri, 9 Jul 2004 17:54:52 +0000 (UTC), sunny <sp******@crayn e.org> wrote:
Hi,
I was trying to call a function in an an asm file from a C
file(driver).

In c file the funcrtion is defined as:
extern int foo(int,int);
In the asm file the function is defined as _foo.

when I link the 2 binaries in VC++ it works fine but with DDK this
gives as error saying _foo@8 not found.

Is there a way to do away with this name mangling.
Since this driver is to be used on both 32 and 64 bit platforms I dont
want the number changing from one version to another.

Thankx a zillion.
Sunil.


Try

extern "C" foo(int, int);

There are no guarantees that this will work, because linking issues and
name mangling are not part of the C++ language. But in many
C++ implementations this has the effect of turning off name mangling.
Jul 22 '05 #3
sunny wrote:
I was trying to call a function in an an asm file from a C
file(driver).

In c file the funcrtion is defined as:
extern int foo(int,int);
Are you sure it's C? It could be C++.
In the asm file the function is defined as _foo.

when I link the 2 binaries in VC++ it works fine but with DDK this
gives as error saying _foo@8 not found.


If it's really C++, add extern "C" to the function declaration (not
"definition ").

--
Phlip
http://industrialxp.org/community/bi...UserInterfaces

Jul 22 '05 #4
sp******@crayne .org (sunny) wrote in message news:<11******* *************** ****@posting.go ogle.com>...
Hi,
I was trying to call a function in an an asm file from a C
file(driver).

In c file the funcrtion is defined as:
extern int foo(int,int);
In the asm file the function is defined as _foo.

when I link the 2 binaries in VC++ it works fine but with DDK this
gives as error saying _foo@8 not found.

Making the definition:

extern "C" {int foo(...);}

should consistently get you an external name with only a leading
underscore and no trailing decoration. Be aware of the distinction
between __cdecl and __stdcall conventions. If you're calling external
code you may want to specify one or the other explicitly, rather than
depending on the compiler command line or default.

Is there a way to do away with this name mangling.
Since this driver is to be used on both 32 and 64 bit platforms I dont
want the number changing from one version to another.

Since you'll need to write a completely different assembler module for
the 64 bit platform(s) you intend to support, there's real no
advantage to having the name consistent between platforms, just so
long as it holds still on any given one.

Jul 22 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
2018
by: Steven Bethard | last post by:
Philippe C. Martin wrote: > class Debug_Stderr: > __m_text = '' > __m_log_text = None > __m_dbg = None > __m_refresh_count = 0 <rant> I don't see the benefit in 99.9% of cases for making class variables
1
2526
by: Tim Slattery | last post by:
Does the C++ language standard mandate a particular name-mangling method? I'm trying to use the Entrust toolkit to create a C++ program that encrypts and decrypts files. Entrust supplies header files defining their objects and functions, and *.so files (I'm on a Sun Sparc machine running Solaris) containing the implementation of the functions. I'm compiling with the GNU g++ compiler. According to the
6
6529
by: yyy | last post by:
my question is rather theoretical than practical in the pure programming aspect... is "name mangling" the same as "name decorating" ? browsing the web, you might find multiple people saying "yes", but i vaguely remember having read that it's not exactly like that one might say that "name mangling" is a part of c++ compiler specification and is a naming scheme to support function overloading
1
1910
by: noleander | last post by:
I need to use a library supplied by someone else: libjpeg.lib. This is a plain C library. I do not have the source code. I do have the header *.h files. When I run dumpbin on the libjpeg.lib, it contains symbols (entry points) like: jpeg_read_header I'm trying to link my program with this library. My program is in Visual C++. The link fails with link-time errors such as:
6
1721
by: David Wade | last post by:
Folks, Does any one know of any "name mangling" software that allows standard C with long names to be linked? Any suggestions for a better place to look? I have tried putting various searchs into google to no avail. Dave.
5
1967
by: Subhransu Sahoo | last post by:
Hi All, Does the C++ standard tell function overloading can't be done with the return types of two functions ? If so, is it true that the name mangling scheme does not take the return type into account ?I know that C++ standard does not tell anything about name mangling and only talks bout function overloading. But, I have observed that the Metrowerks Code Warrior compiler does take return type into the mangling scheme. Is it not a bug...
8
3141
by: sam_cit | last post by:
Hi Everyone, I read somwhere that c++ compiler does name mangling of functions which is why c source code can't invoke functions from object files that were generated using c++ compiler. Can anyone tell in detail as to what name mangling is all about?
4
1974
by: jason.cipriani | last post by:
Does anybody know if C++0x is going to change C++ name mangling at all? Such as, standardizing name mangling instead of leaving it up to the compiler? Jason
14
3002
by: Megalo | last post by:
why not make "name mangling" of C++ standard so should be possible to call the classes and the functions of C++ from other C++ compiler thanks
0
10644
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10394
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10127
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9201
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7665
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6882
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5552
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3863
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3015
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.