5 Replies Latest reply on Dec 11, 2014 11:06 AM by jblackston

    va_start & va_end

    jblackston

      I'm having a problem with the compiler not able to resolve va_start and va_end. At one point I didn't have this issue, so I'm not sure where this is coming from. I went back to the original iotdk-ide-win files to make sure it wasn't caused by any library updates but it's still present. I can find the <stdagr.h> file no problem, so not really sure why it says it can't resolve those two functions. Any ideas?

        • 1. Re: va_start & va_end
          deium

          Hey jblackston,

           

          could you post the code?  Also check <stdagr.h> with <stdarg.h>

          • 2. Re: va_start & va_end
            jblackston

            I think it might have been due to header conflicts. I created a separate file and placed the code in there and it all compiled. Strange... I've noticed this a few times with GNU compilers that sometimes depending upon how the headers are arranged or includes in other files they cancel each other out or cause issues when in one file it might not be seen inside.

             

            Here is the code, it's straight forward:

             

            void CString::Format(TCHAR* formatStr /*in*/, ...)

            {

               Empty();

             

               va_list args;
               TCHAR     text[MAX_PATH];

             

               va_start(args, formatStr);
               vsnprintf(text, MAX_PATH, formatStr, args);
               va_end(args);

             

               (*this) = text;

            }

             

            But I was including a lot in one file like string, stdio, stdlib, stdio, ect... and I think it just messed the compiler up.

            • 3. Re: va_start & va_end
              KurtE

              Note: with some Arduino IDEs, it appears like <stdarg.h> is included by default.

               

              I have found on others such as this one, I have to explicitly include <stdarg.h>

              For example I use it in my Phoenix code (Hexapod), where I have simple function that tries to play notes...

               

              void MSound(byte cNotes, ...)

              {

                va_list ap;

                unsigned int uDur;

                unsigned int uFreq;

                va_start(ap, cNotes);

               

                while (cNotes > 0) {

                  uDur = va_arg(ap, unsigned int);

                  uFreq = va_arg(ap, unsigned int);

                  SoundNoTimer(uDur, uFreq);

                  cNotes--;

                }

                va_end(ap);

              }

              • 4. Re: va_start & va_end
                deium

                jblackston, I confirmed no problems, so this is resolved for you now?

                • 5. Re: va_start & va_end
                  jblackston

                  I think I was over loading a file with header includes which for the GNU compiler seemed to cancel or cause issues with previously included header files.

                   

                  Yes, I did get it this resolved...