I need to overload Dll Exported function, and the problem i'm getting is thet the compiller says only one overloaded function can be "C", how can i do this ?

extern "C" __declspec(dllexport) __stdcall void CreateCustomers(TComponent *Owner);

this is the original declaration, i'm tying to overload it so here is the heder i'm compiling

#ifndef DllH
#define DllH
#include "CustomersForm.h"
extern TCustomersF* DllCustomers;
extern "C" __declspec(dllexport) __stdcall void CreateCustomers(TComponent *Owner);
extern "C" __declspec(dllexport) __stdcall void CreateCustomers(TComponent *Owner, AnsiString Caprion);


Recommended Answers

All 8 Replies

If you want to overload a C function, you need to do your own name mangling so that it has a unique name without any help from the compiler.

So dowe it mean i can not reload the function, i need to have just a different name for the function?
so it is not possible to have to functinos under one name?

Well you could declare it as CreateCustomers(TComponent *Owner, ... ); IF it's possible to look at Owner, AND figure out from that what the rest of the parameters should be.

> so it is not possible to have to functinos under one name?
Create your own really simple class around the API you're given (perhaps), which provides you with all the overloading you want.

I'm sorry but i'm not experianced enoff to figer it out, did not i've done it in

extern "C" __declspec(dllexport) __stdcall void CreateCustomers(TComponent *Owner, AnsiString Caprion);

ore you mean thet the parrameter is supposed to be a pointer?

Look at how printf is called with varying numbers of parameters.
In order to make sense of it all, you look at the first parameter.

It's about as close to overloading as you're going to get in C, without something really horrible and messy.

Why don't you just give me simple, why you are trying to make me work so hard ? I do like to find ansfers by myself but i'm so tired today, i spand all night fighting with. please give me the ansfer for the problem.

There is no "simple".
Fundamentally, there is no overloading in C - period.
There's just a bunch of hacks which could loosely be described as "good", "bad" and "ugly".

Since you've given minimal information (like are you even allowed to change the C code?), it's just vague suggestions based on what might be possible.

Oh, and get some sleep. As often as not, I find the answer to be so obvious in the morning I wondered what the hell the problem was the night before that I couldn't see it.

See you in the morning, cos I'm about done for the night as well.

Thanks, man!!!
It's only 3PM in colorado, so got 2 hours more to work

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.