This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Where is definition of _va_argref and _va_parmadr ?



Hi,

Now i am considering to add a function with variable arguments.  so <stdarg.h> is included into my project,  in this header file, the definition of va_start is as below,

 

#define va_start(_ap, _parmN) \

         (_ap = ((char *)__va_parmadr(_parmN)) + \

  (__va_argref(_parmN) ? sizeof(&_parmN) : \

  (sizeof(_parmN) < 4 ? 4 : sizeof(_parmN))))

 

But I 'd like to know the definition of __va_parmadr and __va_argref as well,   Where could I find them, thanks.  I am using Faraday chip (6488).

  • __va_parmadr and __va_argref are special operators intended for use only in the stdarg.h macros.  They are not documented.  Please do not try to reverse engineer them in some attempt to use them in your own code.  We may change how these operators work in a future release.

    Thanks and regards,

    -George

  • Your answer is understandable, however you did not even try to answer the question. Looking into a header file to understand what it is used for is perfectly understandable. I don't know what these operators do, therefore I am limited in my understanding of what exactly the va_start does, which will in turn cascade into my lack of understanding stdarg.h as a whole. So here in lies the question, why use stdarg.h if I can't understand it? I'm not asking for an implementation, and I don't think Tom is as well. What does __va_parmadr and __va_argref do with the argument _parmN? I think it's a simple question and deserves a simple answer and not what feels like a polite cold shoulder. I would not wish to stay in the dark about the features of an possibly important header file. But hey, maybe I'm just being too picky.

    If this is offensive, I apologize.

    Thanks and regards to you as well,

    Jaz Isom
    Itron, Inc.
  • The va_start and va_arg macros are fully specified in the C standard. These macros are full of compiler magic, and it is going to be a lot harder to understand them by reading the header files than by reading the standard. George has warned you away from reading the source code of stdarg.h because it is very difficult to understand, and will not help you with anything else. If you really want to know, by all means have a look, but we're not going to document these builtins.
  • I still stand by my answer.  That said, I am happy to explain more of the rationale behind that answer.

    Jaz Isom42 said:
    I am limited in my understanding of what exactly the va_start does

    The macro va_start, provided in the header file stdarg.h, is specified by the ANSI standard for C.  Therefore, you can learn how to use it from your favorite book or web site about C.  Learning about a macro or function by reading the implementation often works in other cases, but not with va_start.  It is just too compiler specific, too odd.  This is true not only of TI compilers, but other compilers as well.

    To correctly use va_start does not require you to understand the details of the implementation.  It so happens the implementation, at this time, uses the special operators __va_argref and __va_parmadr.  These operators are not part of the public interface of the compiler.  TI reserves the right to change or remove these operators at any time, with no notice.  That being the case, it is wise to discourage their use in general C code.  Similar things can be said of any other internal implementation detail of the compiler.

    Thanks and regards,

    -George