Josemi
Josemi

Reputation: 156

va_list in C++ 64 Bits

I work with VS2500 and now I want to compile my application under x64 bits but the compiler show me an error:

error C3861: '_INTSIZEOF': identifier was not found

What can I do to solve it?

Upvotes: 0

Views: 1643

Answers (3)

Josemi
Josemi

Reputation: 156

Right. The problem was that I use "va_start" in my routine and more specifically a solution given by "http://www.codeproject.com/Articles/4181/Variable-Argument-Functions?msg=4204968#xx4204968xx" solution that works perfectly in Win32, but not on x64 does that not allow use __ asm. example:

# define va_start (ap, v) {int var = _INTSIZEOF (v); __ asm read eax, v add eax __ asm, __ asm mov var ap, eax}

 float add (float &x, ...) {

 va_list list;
 va_start (list, x);

 float result = 0;

 for (;;)
 {
 float p = (float) va_arg (list, double);
 if (p == 0)
 break;
 result + = p;

 }
 va_end (list);
 return result;

 }

 int main () {

 float hh = 2.1;
 cout << "Result is" << add (/ * 2.1 * / hh, 4.3,6.8);
 return 0;

 }

Now I have the problem that __ asm does not work on x64, but I can to solve it if I remove "&" like: "float add (float x, ...) {"

Upvotes: 0

Michael Burr
Michael Burr

Reputation: 340188

You have to include <stdarg.h> to use va_list.

That will bring in the necessary definition for _INTSIZEOF.


Actually, on closer look - when compiling for x64 (or amd64) VS 2005 doesn't seem to use _INTSIZE in its stdarg.h implementation. What line of code is generating the error, and are you sure you have you project configured correctly for an x64 build?

I'd especially look at include files paths (setting the /showIncludes option might point out problems with incorrect headers being pulled in). Your build should pick up stdarg.h and vadefs.h from:

Microsoft Visual Studio 8\VC\include

Upvotes: 1

House.Lee
House.Lee

Reputation: 251

it seems that ur compiler does not originally supported this MACRO, so u might try to add these in the front of ur code: #define _INTSIZEOF(n) ((sizeof(n)+sizeof(int)-1)&~(sizeof(int) - 1) )

Upvotes: 0

Related Questions