Name disamb. in multifile project

This is a discussion on Name disamb. in multifile project within the C Programming forums, part of the General Programming Boards category; Hello, I'm working on a program that should manage data structures like queues and stacks. For exercise, I made structs ...

  1. #1
    Registered User
    Join Date
    Jun 2006
    Posts
    22

    Name disamb. in multifile project

    Hello, I'm working on a program that should manage data structures like queues and stacks.
    For exercise, I made structs to model those structures, using two different .c files, each with the struct and the methods.

    Now the problem is: if I include my files in a main program, there's name ambiguity. Both structures have "empty" and "null" methods.
    Is there a way to disambiguate the methods without changing the name? Of course first solution is change empty(..) to emptyQueue(...) but is tricky and annoying to use.
    Maybe namespaces? I know about their existence but I dont know how to use them.

    Thanks for help!

  2. #2
    ZuK
    ZuK is offline
    Registered User
    Join Date
    Aug 2005
    Location
    Austria
    Posts
    1,990
    Quote Originally Posted by gibbofresco View Post
    Maybe namespaces? I know about their existence but I dont know how to use them.
    Works for C++ only.
    Kurt

  3. #3
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,274
    Quote Originally Posted by gibbofresco View Post
    Now the problem is: if I include my files in a main program, there's name ambiguity. Both structures have "empty" and "null" methods.
    A method? This is C, there is no such thing. If you mean you have FUNCTION POINTERS in these structs, there's no reason why the names of those members can't be the same. I think you are not describing correctly what you actually have. Code?

    If you're talking about functions which OPERATE on those structs, then no. Those functions may not have the same name.

    Is there a way to disambiguate the methods without changing the name? Of course first solution is change empty(..) to emptyQueue(...) but is tricky and annoying to use.
    Tricky? Annoying? I'd say it's more tricky and annoying to have to GUESS which function is correct. Putting the "Queue" on "emptyQueue" makes the function EASIER to understand, I think.

    Maybe namespaces? I know about their existence but I dont know how to use them.
    No such thing.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem Displaying a Struct
    By rockstarpirate in forum C++ Programming
    Replies: 16
    Last Post: 05-05-2008, 10:05 AM
  2. added start menu crashes game
    By avgprogamerjoe in forum Game Programming
    Replies: 6
    Last Post: 08-29-2007, 02:30 PM
  3. Dynamic Binding
    By gpr1me in forum C++ Programming
    Replies: 1
    Last Post: 03-24-2006, 09:01 AM
  4. Game Independent Anti-cheat Project Needs Programmers
    By GIA Project Lea in forum Projects and Job Recruitment
    Replies: 3
    Last Post: 09-15-2005, 08:41 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21