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. Function Traceback

Function Traceback

Scheduled Pinned Locked Moved C / C++ / MFC
question
8 Posts 4 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.
  • S Offline
    S Offline
    Suvendra
    wrote on last edited by
    #1

    Hi All, Is there a way to know the reference to the calling function at runtime without using some flag variables? For eg. void foo() {     foobar(); } void bar() {     foobar(); } void foobar() {     /* What will be the condition for this IF? */     if (calling function is 'foo') {         bla... bla..     } else {         bla... bla..     } } Thanks.

    D 1 Reply Last reply
    0
    • S Suvendra

      Hi All, Is there a way to know the reference to the calling function at runtime without using some flag variables? For eg. void foo() {     foobar(); } void bar() {     foobar(); } void foobar() {     /* What will be the condition for this IF? */     if (calling function is 'foo') {         bla... bla..     } else {         bla... bla..     } } Thanks.

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      The only thing I can think of it to pass an argument to the foobar() function.


      "Take only what you need and leave the land as you found it." - Native American Proverb

      S 1 Reply Last reply
      0
      • D David Crow

        The only thing I can think of it to pass an argument to the foobar() function.


        "Take only what you need and leave the land as you found it." - Native American Proverb

        S Offline
        S Offline
        Suvendra
        wrote on last edited by
        #3

        DavidCrow wrote:

        The only thing I can think of it to pass an argument to the foobar() function.

        Thanks David. But maybe I did not put my question correctly. I have a library and I want to hide a function from direct calling by functions which are external to the library. Kind of like keeping it in private: section of a C++ class. But the problem is, I want the library in pure C and not C++. So, my library function 'foo()' should be able to invoke foobar() correctly. However, if an external function bar() tries to invoke it, the library should be able to correctly identify it and return appropriate error. Appreciate your help.

        D M 2 Replies Last reply
        0
        • S Suvendra

          DavidCrow wrote:

          The only thing I can think of it to pass an argument to the foobar() function.

          Thanks David. But maybe I did not put my question correctly. I have a library and I want to hide a function from direct calling by functions which are external to the library. Kind of like keeping it in private: section of a C++ class. But the problem is, I want the library in pure C and not C++. So, my library function 'foo()' should be able to invoke foobar() correctly. However, if an external function bar() tries to invoke it, the library should be able to correctly identify it and return appropriate error. Appreciate your help.

          D Offline
          D Offline
          David Crow
          wrote on last edited by
          #4

          Even with these new constraints, my suggestion will still work. All you have to do is choose a number to pass to the exported foobar() function that will likely not be guessed by others.


          "Take only what you need and leave the land as you found it." - Native American Proverb

          S 1 Reply Last reply
          0
          • S Suvendra

            DavidCrow wrote:

            The only thing I can think of it to pass an argument to the foobar() function.

            Thanks David. But maybe I did not put my question correctly. I have a library and I want to hide a function from direct calling by functions which are external to the library. Kind of like keeping it in private: section of a C++ class. But the problem is, I want the library in pure C and not C++. So, my library function 'foo()' should be able to invoke foobar() correctly. However, if an external function bar() tries to invoke it, the library should be able to correctly identify it and return appropriate error. Appreciate your help.

            M Offline
            M Offline
            Maximilien
            wrote on last edited by
            #5

            I'm not certain that you can hide functions in a library; hackers will find the name and arguments for it in the library ( but I might be wrong ) If the function is not "published" in a header file, a normal user will not call it.


            Maximilien Lincourt Your Head A Splode - Strong Bad

            S J 2 Replies Last reply
            0
            • D David Crow

              Even with these new constraints, my suggestion will still work. All you have to do is choose a number to pass to the exported foobar() function that will likely not be guessed by others.


              "Take only what you need and leave the land as you found it." - Native American Proverb

              S Offline
              S Offline
              Suvendra
              wrote on last edited by
              #6

              DavidCrow wrote:

              Even with these new constraints, my suggestion will still work. All you have to do is choose a number to pass to the exported foobar() function that will likely not be guessed by others.

              You are right. That is a Workable solution. Thanks David.

              1 Reply Last reply
              0
              • M Maximilien

                I'm not certain that you can hide functions in a library; hackers will find the name and arguments for it in the library ( but I might be wrong ) If the function is not "published" in a header file, a normal user will not call it.


                Maximilien Lincourt Your Head A Splode - Strong Bad

                S Offline
                S Offline
                Suvendra
                wrote on last edited by
                #7

                Maximilien wrote:

                If the function is not "published" in a header file, a normal user will not call it.

                I agree with you on that. Thanks Maximilien.

                1 Reply Last reply
                0
                • M Maximilien

                  I'm not certain that you can hide functions in a library; hackers will find the name and arguments for it in the library ( but I might be wrong ) If the function is not "published" in a header file, a normal user will not call it.


                  Maximilien Lincourt Your Head A Splode - Strong Bad

                  J Offline
                  J Offline
                  Jorgen Sigvardsson
                  wrote on last edited by
                  #8

                  > a normal user will not call it. Does that make me abnormal? :rolleyes: -- Pictures[^] from my Japan trip.

                  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