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. __VAR_ARGS__

__VAR_ARGS__

Scheduled Pinned Locked Moved C / C++ / MFC
csharpvisual-studiohelptutorialquestion
9 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.
  • L Offline
    L Offline
    Like2Byte
    wrote on last edited by
    #1

    Hi all. I'm implementing a macro that I need to have take multiple parameters. Let's say I'm implementing a printf macro. (I know. I know. Just run with me for the example. :-D ) #define PRINT(str,...) printf(str,__VAR_ARGS__); Well, obviously, someone could invoke the macro thusly: PRINT("My name is %s and I am %i years old.", szName, iAge); After doing some research, I found __VAR_ARGS__ on gamedev.net. Just one problem: Visual Studio 2008 is not aware for __VAR_ARGS__. Am I misspelling __VAR_ARGS__ or something? What header file is __VAR_ARGS__ (or its correctly spelled version!!) defined? K, thanks!

    L S 2 Replies Last reply
    0
    • L Like2Byte

      Hi all. I'm implementing a macro that I need to have take multiple parameters. Let's say I'm implementing a printf macro. (I know. I know. Just run with me for the example. :-D ) #define PRINT(str,...) printf(str,__VAR_ARGS__); Well, obviously, someone could invoke the macro thusly: PRINT("My name is %s and I am %i years old.", szName, iAge); After doing some research, I found __VAR_ARGS__ on gamedev.net. Just one problem: Visual Studio 2008 is not aware for __VAR_ARGS__. Am I misspelling __VAR_ARGS__ or something? What header file is __VAR_ARGS__ (or its correctly spelled version!!) defined? K, thanks!

      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #2

      varargs.h by any chance? :confused:

      Luc Pattyn [Forum Guidelines] [My Articles]


      Fixturized forever. :confused:


      L 2 Replies Last reply
      0
      • L Luc Pattyn

        varargs.h by any chance? :confused:

        Luc Pattyn [Forum Guidelines] [My Articles]


        Fixturized forever. :confused:


        L Offline
        L Offline
        Like2Byte
        wrote on last edited by
        #3

        Well, actually, I think I figured it out. It's: __VA_ARGS__ #define PRINT(str,...) printf(str, __VA_ARGS__); //not __VAR_ARGS__ lose the first 'R'.

        L 1 Reply Last reply
        0
        • L Like2Byte

          Well, actually, I think I figured it out. It's: __VA_ARGS__ #define PRINT(str,...) printf(str, __VA_ARGS__); //not __VAR_ARGS__ lose the first 'R'.

          L Offline
          L Offline
          Luc Pattyn
          wrote on last edited by
          #4

          indeed, however vaargs.h won't cut it. :)

          Luc Pattyn [Forum Guidelines] [My Articles]


          Fixturized forever. :confused:


          L 1 Reply Last reply
          0
          • L Luc Pattyn

            varargs.h by any chance? :confused:

            Luc Pattyn [Forum Guidelines] [My Articles]


            Fixturized forever. :confused:


            L Offline
            L Offline
            Like2Byte
            wrote on last edited by
            #5

            I searched for varargs.h and only my WinARM and cygwin directories have those files. Still searching the tree for __VA_ARGS__.

            L 1 Reply Last reply
            0
            • L Luc Pattyn

              indeed, however vaargs.h won't cut it. :)

              Luc Pattyn [Forum Guidelines] [My Articles]


              Fixturized forever. :confused:


              L Offline
              L Offline
              Like2Byte
              wrote on last edited by
              #6

              hehe. Yeah, I'm still searching for where __VA_ARGS__ *is* defined. I wonder if it's hardcoded into the compiler itself. The C99 standard says it should be supported - whether MS supports it or not I'm truly not at liberty to say until I've tested my still compiling application. (~700K lines).

              1 Reply Last reply
              0
              • L Like2Byte

                I searched for varargs.h and only my WinARM and cygwin directories have those files. Still searching the tree for __VA_ARGS__.

                L Offline
                L Offline
                Luc Pattyn
                wrote on last edited by
                #7

                Hi, my folder C:\Program Files\Microsoft Visual Studio 9.0\VC\include holds a varargs.h file containing definitions for _VA_LIST, va_start(ap), va_arg(ap,t), and more. Yes, __VA_ARGS__ seems not to be there, I think you're right the compiler knows all about that one without any include file. [ADDED] Their documentation[^] knows about it; and you could test it with a much smaller program... [/ADDED] :)

                Luc Pattyn [Forum Guidelines] [My Articles]


                Fixturized forever. :confused:


                modified on Tuesday, December 9, 2008 1:09 PM

                L 1 Reply Last reply
                0
                • L Luc Pattyn

                  Hi, my folder C:\Program Files\Microsoft Visual Studio 9.0\VC\include holds a varargs.h file containing definitions for _VA_LIST, va_start(ap), va_arg(ap,t), and more. Yes, __VA_ARGS__ seems not to be there, I think you're right the compiler knows all about that one without any include file. [ADDED] Their documentation[^] knows about it; and you could test it with a much smaller program... [/ADDED] :)

                  Luc Pattyn [Forum Guidelines] [My Articles]


                  Fixturized forever. :confused:


                  modified on Tuesday, December 9, 2008 1:09 PM

                  L Offline
                  L Offline
                  Like2Byte
                  wrote on last edited by
                  #8

                  /hug See, this is why I love The Code Project! Thank you, Luc!

                  1 Reply Last reply
                  0
                  • L Like2Byte

                    Hi all. I'm implementing a macro that I need to have take multiple parameters. Let's say I'm implementing a printf macro. (I know. I know. Just run with me for the example. :-D ) #define PRINT(str,...) printf(str,__VAR_ARGS__); Well, obviously, someone could invoke the macro thusly: PRINT("My name is %s and I am %i years old.", szName, iAge); After doing some research, I found __VAR_ARGS__ on gamedev.net. Just one problem: Visual Studio 2008 is not aware for __VAR_ARGS__. Am I misspelling __VAR_ARGS__ or something? What header file is __VAR_ARGS__ (or its correctly spelled version!!) defined? K, thanks!

                    S Offline
                    S Offline
                    Stuart Dootson
                    wrote on last edited by
                    #9

                    Looking at this page about variadic macros[^], it should be __VA_ARGS__? You won't find it in any header file, though, because it's something built into the pre-processor.

                    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