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. Variadic Macros

Variadic Macros

Scheduled Pinned Locked Moved C / C++ / MFC
c++comhelpquestion
6 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.
  • A Offline
    A Offline
    Arsalan Malik
    wrote on last edited by
    #1

    I want to use variadic macros in C using Visual C++ 6.0, as explained in MSDN[^]: #define CHECK1(x, ...) if (!(x)) { printf(__VA_ARGS__); } The compiler is giving me C2010 error X| . Is it supported in Visual C++ 6.0?:~ If yes, what should I do to compile this code? If there is an alternate to variadic macros in C, it will be helpfull.

    ARSALAN MALIK

    T M 2 Replies Last reply
    0
    • A Arsalan Malik

      I want to use variadic macros in C using Visual C++ 6.0, as explained in MSDN[^]: #define CHECK1(x, ...) if (!(x)) { printf(__VA_ARGS__); } The compiler is giving me C2010 error X| . Is it supported in Visual C++ 6.0?:~ If yes, what should I do to compile this code? If there is an alternate to variadic macros in C, it will be helpfull.

      ARSALAN MALIK

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

      #define CHECK1(x, args) if (!(x)) { printf(args); }

      BTW, i have a question. why do you want to do such a thing ? to print only in debug ? if so, you could do a better design, like this :

      #if defined(DEBUG) ||defined(_DEBUG)
      #define DBG_PRINT printf
      #else
      #define int DBG_PRINT(const char*, ...) { return 0; }
      #endif

      this way, you can place some DBG_PRINT("whatever"); in you code ; it will be executed only in debug mode compilation. -- modified at 5:38 Tuesday 25th July, 2006

      A 1 Reply Last reply
      0
      • T toxcct

        #define CHECK1(x, args) if (!(x)) { printf(args); }

        BTW, i have a question. why do you want to do such a thing ? to print only in debug ? if so, you could do a better design, like this :

        #if defined(DEBUG) ||defined(_DEBUG)
        #define DBG_PRINT printf
        #else
        #define int DBG_PRINT(const char*, ...) { return 0; }
        #endif

        this way, you can place some DBG_PRINT("whatever"); in you code ; it will be executed only in debug mode compilation. -- modified at 5:38 Tuesday 25th July, 2006

        A Offline
        A Offline
        Arsalan Malik
        wrote on last edited by
        #3

        #define CHECK1(x, args) if (!(x)) { printf(args); }

        How do I pass multiple arguments, e.g. I want printf("%i %i", a, b); :doh:

        #if defined(DEBUG) ||defined(_DEBUG)
        #define DBG_PRINT printf
        #else
        #define int DBG_PRINT(const char*, ...) { return 0; }
        #endif

        This does not compile under VC6:->

        ARSALAN MALIK

        T 1 Reply Last reply
        0
        • A Arsalan Malik

          I want to use variadic macros in C using Visual C++ 6.0, as explained in MSDN[^]: #define CHECK1(x, ...) if (!(x)) { printf(__VA_ARGS__); } The compiler is giving me C2010 error X| . Is it supported in Visual C++ 6.0?:~ If yes, what should I do to compile this code? If there is an alternate to variadic macros in C, it will be helpfull.

          ARSALAN MALIK

          M Offline
          M Offline
          Michael Dunn
          wrote on last edited by
          #4

          VC 6 doesn't support that feature, sorry.

          --Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ

          N 1 Reply Last reply
          0
          • A Arsalan Malik

            #define CHECK1(x, args) if (!(x)) { printf(args); }

            How do I pass multiple arguments, e.g. I want printf("%i %i", a, b); :doh:

            #if defined(DEBUG) ||defined(_DEBUG)
            #define DBG_PRINT printf
            #else
            #define int DBG_PRINT(const char*, ...) { return 0; }
            #endif

            This does not compile under VC6:->

            ARSALAN MALIK

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

            Arsalan Malik wrote:

            This does not compile under VC6

            yes i made a mistake. remove the #define leading on the #else case...


            TOXCCT >>> GEII power

            [VisualCalc 3.0  updated ][Flags Beginner's Guide  new! ]

            1 Reply Last reply
            0
            • M Michael Dunn

              VC 6 doesn't support that feature, sorry.

              --Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ

              N Offline
              N Offline
              Naveen
              wrote on last edited by
              #6

              Michael Dunn wrote:

              VC 6 doesn't support that feature

              What about VC 7 ?

              nave

              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