473,325 Members | 2,872 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

Namespaces clash in C

Hi all,

In a software stack, I have an upper layer & lower layer both from
different vendors.
The lower layer (is in the form of libraries) exports some functions
say for eg: semaphore_delete(). Unfortunately, the
upper layer (is in the form of header files) also provides prototypes
for the functions whose names match exactly with the
function names exported by the lower layer. That is, the upper layer
header file has a prototype for semaphore_delete().

I want to implement this upper layer semaphore_delete()
using the lower layer semaphore_delete() function. But these 2
namespaces are clashing. I know that this problem could have
been easily solved in C++ using its namespace feature. But C
does not have this feature and hence how do I solve this problem in C.?
Has anyone come across similar kind of
problems.?

regards,
Raghunath

Nov 15 '05 #1
4 1974
bn*******@yahoo.com wrote:

<snip>
I want to implement this upper layer semaphore_delete()
using the lower layer semaphore_delete() function. But these 2
namespaces are clashing. I know that this problem could have
been easily solved in C++ using its namespace feature. But C
does not have this feature and hence how do I solve this problem in C.?
Has anyone come across similar kind of
problems.?


The only way to resolve a name clash on external symbol names (such as
exported functions) in standard C is to rename one of them. Obviously
you can only do this with something you have the source code for.

Your best bet is probably contacting the vendors involved and asking for
their assistance. Or checking to see if they have support groups or
mailing lists you can ask in.

There *may* also be system specific methods of resolving the problem,
but any such methods would be off topic here and, in my opinion, if you
don't know exactly what the repercussions will be such methods are
dangerous.

Asking here if C has a solution was reasonable, unfortunately for you
the solution is going to be outside the realms of standard C and hence
we can't help you here.
--
Flash Gordon
Living in interesting times.
Although my email address says spam, it is real and I read it.
Nov 15 '05 #2
<bn*******@yahoo.com> schreef in bericht
news:11**********************@g44g2000cwa.googlegr oups.com...
Hi all,

In a software stack, I have an upper layer & lower layer both from
different vendors.
The lower layer (is in the form of libraries) exports some functions
say for eg: semaphore_delete(). Unfortunately, the
upper layer (is in the form of header files) also provides prototypes
for the functions whose names match exactly with the
function names exported by the lower layer. That is, the upper layer
header file has a prototype for semaphore_delete().

I want to implement this upper layer semaphore_delete()
using the lower layer semaphore_delete() function. But these 2
namespaces are clashing. I know that this problem could have
been easily solved in C++ using its namespace feature. But C
does not have this feature and hence how do I solve this problem in C.?
Has anyone come across similar kind of
problems.?

regards,
Raghunath


You could create a layer between the software stacks and your software. A
layer then forms an abstraction of the software stack and since you're the
one who defines the interface of the layers, you can choose your own names.
So in the interface of the stack A you define a function like
A_semaphore_delete() and in the interface of stack B you have something like
B_semaphore_delete().

Regards,
Nathan
Nov 15 '05 #3
Hi,

Thank you very much for this response. I'll give it a try.

regards,
Raghunath

Nathan Wijnia wrote:
<bn*******@yahoo.com> schreef in bericht
news:11**********************@g44g2000cwa.googlegr oups.com...
Hi all,

In a software stack, I have an upper layer & lower layer both from
different vendors.
The lower layer (is in the form of libraries) exports some functions
say for eg: semaphore_delete(). Unfortunately, the
upper layer (is in the form of header files) also provides prototypes
for the functions whose names match exactly with the
function names exported by the lower layer. That is, the upper layer
header file has a prototype for semaphore_delete().

I want to implement this upper layer semaphore_delete()
using the lower layer semaphore_delete() function. But these 2
namespaces are clashing. I know that this problem could have
been easily solved in C++ using its namespace feature. But C
does not have this feature and hence how do I solve this problem in C.?
Has anyone come across similar kind of
problems.?

regards,
Raghunath


You could create a layer between the software stacks and your software. A
layer then forms an abstraction of the software stack and since you're the
one who defines the interface of the layers, you can choose your own names.
So in the interface of the stack A you define a function like
A_semaphore_delete() and in the interface of stack B you have something like
B_semaphore_delete().

Regards,
Nathan


Nov 15 '05 #4

bn*******@yahoo.com wrote:
Hi all,

In a software stack, I have an upper layer & lower layer both from
different vendors.
The lower layer (is in the form of libraries) exports some functions
say for eg: semaphore_delete(). Unfortunately, the
upper layer (is in the form of header files) also provides prototypes
for the functions whose names match exactly with the
function names exported by the lower layer. That is, the upper layer
header file has a prototype for semaphore_delete().

I want to implement this upper layer semaphore_delete()
using the lower layer semaphore_delete() function. But these 2
namespaces are clashing. I know that this problem could have
been easily solved in C++ using its namespace feature. But C
does not have this feature and hence how do I solve this problem in C.?
Has anyone come across similar kind of
problems.?

regards,
Raghunath


If you object to renaming your version of the function (used
in too many places?), perhaps you could use macros to achieve
your ends.

Example:

Header file:
#define semaphore_delete my_semaphore_delete
void semaphore_delete(...);

Your file that implements my_semaphore_delete
includes that header and does
#undefine semaphore_delete

It then implements my_semaphore_delete, and calls
underlying the semaphore_delete.

Ugly, perhaps, but I think it works...

-David

Nov 15 '05 #5

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

Similar topics

18
by: Steven Bethard | last post by:
In the "empty classes as c structs?" thread, we've been talking in some detail about my proposed "generic objects" PEP. Based on a number of suggestions, I'm thinking more and more that instead of...
24
by: Marcin Vorbrodt | last post by:
Here is an example of my code: //Header file #include <vector> using std::vector; namespace Revelation { // class definitions, etc... // class members are of type std::vector }
1
by: Steven T. Hatton | last post by:
A while back I posted some code along with an error message I got when I tried to compile it. I thought at one point I had solved all the problems. But then I tried it again, and if failed. The...
3
by: Rubén Campos | last post by:
Organizing classes, types, structures, enums and whatever other entities into nested namespaces requires to include into every header and implementation file the complete path of namespaces. Let me...
15
by: Stuart | last post by:
I work in a small company with developers who do not like to use "new" features when they find the old ones sufficient. e.g. given a choice between a class and a namespace, they'll pick class. ...
11
by: Random | last post by:
I'm confused about the proper use and usefulness of namespaces. I beleive I understand the purpose is so the developer can put classes within namespaces to essentially organize your code. And I...
2
by: Deepa K | last post by:
Hi, In my PC, eth0 is not up because of IP address clash (another PC is using the same IP address). I tried to execute a file which has set of insert commands. After executing the file, when I go...
1
by: David Gaudine | last post by:
(This is a bit like the recent thread "PHP Switching Sessions".) I use session_start(). When I open my web-based application in two windows on the same system, there's a definite clash; I can't...
0
by: smoothkriminal1 | last post by:
the question is u read timetable of 40 students from file n den find da slot where all fourty students dnt hve clash...if any.... may b i ll be able to make clash logic but i m even just nt...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.