Problem with va_list in VC++ 6.0/2002/2003 Final Beta 
Author Message
 Problem with va_list in VC++ 6.0/2002/2003 Final Beta

Consider the following:

void F(unsigned, va_list)
{
        std::cout << "In va_list version" << std::endl;

Quote:
}

void F(unsigned, ...)
{
        std::cout << "In ... version" << std::endl;

Quote:
}

int _tmain(int argc, _TCHAR* argv[])
{
        F(0, 0);
        F(0, 1);
        return 0;

Quote:
}

Which F() functions should be called?  For the F(0, 0)
call, the va_list overload is called because va_list is
typedef'ed to char*.

How do you get it to call the ... version?  I've tried 0u
and 0L without success.  If I define an int variable,
the ... version is called.  Is there another way?



Tue, 16 Aug 2005 07:06:59 GMT  
 Problem with va_list in VC++ 6.0/2002/2003 Final Beta

Quote:

>Consider the following:

>void F(unsigned, va_list)
>{
>    std::cout << "In va_list version" << std::endl;
>}

>void F(unsigned, ...)
>{
>    std::cout << "In ... version" << std::endl;
>}

>int _tmain(int argc, _TCHAR* argv[])
>{
>    F(0, 0);
>    F(0, 1);
>    return 0;
>}

>Which F() functions should be called?  For the F(0, 0)
>call, the va_list overload is called because va_list is
>typedef'ed to char*.

>How do you get it to call the ... version?  I've tried 0u
>and 0L without success.  If I define an int variable,
>the ... version is called.  Is there another way?

The pointer conversion of integral constant zero to null pointer constant is
a better match than the ellipsis conversion. I think the best solution is to
avoid overloading on ellipsis and follow the Standard C library in naming
that form of "F" something like "vF". Otherwise, I guess you could overload
F on all integral types at least as big as int, relying on integral
promotions for the smaller types.

--
Doug Harrison
Microsoft MVP - Visual C++



Tue, 16 Aug 2005 09:54:26 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. VC 2003 final beta

2. Koenig Lookup in VC++ 2003 Final Beta

3. VC++ .Net 2003 Final Beta Issue #2

4. Converting project from VC++ 2002 to VC++ 2003 and adding a new configuration

5. Converting project from VC++ 2002 to VC++ 2003 and adding a new configuration

6. VS 2003 final beta C1001: another ICE

7. Possible C++ bug .NET 2003 Final Beta

8. Syntax Error in Templates in 2003 Final Beta Compiler

9. optimizer bug in VC7.1 final beta Visual Studio .Net 2003

10. Bugs in Visual C++ 2003 Final Beta

11. Possible bug: MIDL properties missing in VS.NET 2003 Final Beta

12. How to I move my VS 2002 Add-Ins to VS2003 Final Beta

 

 
Powered by phpBB® Forum Software