Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Decorated names prefix

Decorated names prefix

Scheduled Pinned Locked Moved C / C++ / MFC
question
10 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Mauro Leggieri
    wrote on last edited by
    #1

    Hi, In order to avoid naming conflicts between different libraries, and avoiding changing names to functions, is there any way to add some "prefix" or suffix to the decorated name that the compiler generates, via, for e.g., a #pragma? I don't believe it is possible, but if it is, please post the answer. Best regards, Mauro.

    T R 2 Replies Last reply
    0
    • M Mauro Leggieri

      Hi, In order to avoid naming conflicts between different libraries, and avoiding changing names to functions, is there any way to add some "prefix" or suffix to the decorated name that the compiler generates, via, for e.g., a #pragma? I don't believe it is possible, but if it is, please post the answer. Best regards, Mauro.

      T Offline
      T Offline
      toxcct
      wrote on last edited by
      #2

      are you in a particuliar need ?


      [VisualCalc][Binary Guide][CommDialogs] | [Forums Guidelines]

      M 1 Reply Last reply
      0
      • M Mauro Leggieri

        Hi, In order to avoid naming conflicts between different libraries, and avoiding changing names to functions, is there any way to add some "prefix" or suffix to the decorated name that the compiler generates, via, for e.g., a #pragma? I don't believe it is possible, but if it is, please post the answer. Best regards, Mauro.

        R Offline
        R Offline
        Roger Stoltz
        wrote on last edited by
        #3

        Not really sure what you're after, but there's a chance that a namespace would satisfy your needs. Have a look here[^].


        "It's supposed to be hard, otherwise anybody could do it!" - selfquote
        "High speed never compensates for wrong direction!" - unknown

        M 1 Reply Last reply
        0
        • T toxcct

          are you in a particuliar need ?


          [VisualCalc][Binary Guide][CommDialogs] | [Forums Guidelines]

          M Offline
          M Offline
          Mauro Leggieri
          wrote on last edited by
          #4

          Hi, I'm making a personal library for handling images, videos and some other stuff. I use the code of libpng, and libtheora for example. In theora there is a function named "cpu_init" and I haven't conflicts for now but you see it has a "common" name that can be used in other libraries or by me if I have no deep knowledge of internal functions. I wish to add the "theora_" prefix to all functions in libtheora to prevent potential conflicts. If there is no way I should change the names manually. Best regards, Mauro.

          T 1 Reply Last reply
          0
          • R Roger Stoltz

            Not really sure what you're after, but there's a chance that a namespace would satisfy your needs. Have a look here[^].


            "It's supposed to be hard, otherwise anybody could do it!" - selfquote
            "High speed never compensates for wrong direction!" - unknown

            M Offline
            M Offline
            Mauro Leggieri
            wrote on last edited by
            #5

            Hi, Yes it would but namespaces works in C++ and many libraries are in plain C. Best regards, Mauro.

            T 1 Reply Last reply
            0
            • M Mauro Leggieri

              Hi, I'm making a personal library for handling images, videos and some other stuff. I use the code of libpng, and libtheora for example. In theora there is a function named "cpu_init" and I haven't conflicts for now but you see it has a "common" name that can be used in other libraries or by me if I have no deep knowledge of internal functions. I wish to add the "theora_" prefix to all functions in libtheora to prevent potential conflicts. If there is no way I should change the names manually. Best regards, Mauro.

              T Offline
              T Offline
              toxcct
              wrote on last edited by
              #6

              Mauro Leggieri wrote:

              I wish to add the "theora_" prefix to all functions in libtheora

              what about prefixing - like Roger suggested - to prefix with theora:: instead ?


              [VisualCalc][Binary Guide][CommDialogs] | [Forums Guidelines]

              1 Reply Last reply
              0
              • M Mauro Leggieri

                Hi, Yes it would but namespaces works in C++ and many libraries are in plain C. Best regards, Mauro.

                T Offline
                T Offline
                toxcct
                wrote on last edited by
                #7

                if you code in C++, there's no problem... you can import C functions inside it then what do you think the standard C++ library does with the C runtime functions into the std:: namespace ? -- modified at 14:30 Tuesday 20th March, 2007


                [VisualCalc][Binary Guide][CommDialogs] | [Forums Guidelines]

                M 1 Reply Last reply
                0
                • T toxcct

                  if you code in C++, there's no problem... you can import C functions inside it then what do you think the standard C++ library does with the C runtime functions into the std:: namespace ? -- modified at 14:30 Tuesday 20th March, 2007


                  [VisualCalc][Binary Guide][CommDialogs] | [Forums Guidelines]

                  M Offline
                  M Offline
                  Mauro Leggieri
                  wrote on last edited by
                  #8

                  Each C source files in theora generates a .obj file with the possible conflicting public symbols. Encapsulating inside a C++ object doesn't hide public symbols from original theora compiled object files. Code is opensource so I can make things like changing function names but I wish to avoid that in order to make updates easily when there are new versions available. Greetings, Mauro

                  T 1 Reply Last reply
                  0
                  • M Mauro Leggieri

                    Each C source files in theora generates a .obj file with the possible conflicting public symbols. Encapsulating inside a C++ object doesn't hide public symbols from original theora compiled object files. Code is opensource so I can make things like changing function names but I wish to avoid that in order to make updates easily when there are new versions available. Greetings, Mauro

                    T Offline
                    T Offline
                    toxcct
                    wrote on last edited by
                    #9

                    you don't get it. process in 2 steps. firstly, generate a library which will present the theora in your namespace. then, use this "new" library, which won't generate name duplicates anymore, due to the namespace...


                    [VisualCalc][Binary Guide][CommDialogs] | [Forums Guidelines]

                    M 1 Reply Last reply
                    0
                    • T toxcct

                      you don't get it. process in 2 steps. firstly, generate a library which will present the theora in your namespace. then, use this "new" library, which won't generate name duplicates anymore, due to the namespace...


                      [VisualCalc][Binary Guide][CommDialogs] | [Forums Guidelines]

                      M Offline
                      M Offline
                      Mauro Leggieri
                      wrote on last edited by
                      #10

                      Thanks Toxcct 4 answering. Can you explain me more detailed? Imagine I have a C function named myfunc in test1.c Then test1.lib will contain the module test1.obj that contains the _myfunc public symbol. On the other side, another function with the same name but in test2.lib When I link the app with test1.lib and test2.lib the linker gives an error in test2.lib(test2.obj) because _myfunc is already defined in test1.lib(test1.obj) I didn't find to hide test1.obj from the visibility of test2.obj, no matters if it is inside a .lib Best regards, Mauro.

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups