473,770 Members | 2,133 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem with "va_list" & variable arguments in 64-bit programs onSLES 10 SP1

I have some code that is being built on the following:

Windows Server 2003, both 32-bit & 64-bit editions
Windows Vista, both 32-bit & 64-bit editions
Windows Server 2008, both 32-bit & 64-bit editions

Build tools: Visual Studio 2008.

SLES 10 SP1, both 32-bit & 64 bit editions

Build tools: gss v4.1.2
This code has a function that takes a variable # of arguments, and it
serves as a wrapper around various functions in the printf() family,
namely, the "v" variants of them directly accept a "va_list" argument.
The code makes proper use of va_start() and va_end() to initialize an
instance of "va_list", which then gets passed in to vsnprintf() [Linux],
vswprintf() [Linux & Windows] and vsnprintf_s() [Windows].

The code compiles & links successfully for both 32-bit & 64-bit targets
on Windows, and it executes properly, too. It also compiles, links &
executes properly when producing a 32-bit binary on SLES 10 SP1.

Although it compiles & links successfully when producing a 64-bit binary
on SLES 10 SP1, it does not execute properly. The various printf()
functions that are being called all fail to produce proper output.

After simultaneously debugging both the 32-bit & 64-bit builds of the
program, and also comparing with what's happening on Windows, I've
obtained the following information:

On Windows, for both 32-bit & 64-bit targets, "va_list" is nothing more
than a "char *" pointer that points to a contiguous block of memory that
contains 32-bit values [on 32-bit build] and 64-bit values [on 64-bit
build]. Examining memory at that address value stored in an initialized
instance of "va_list" proves that this is true.

On Linux, for the 32-bit build of the program, "va_list" is also a "char
*", and it behaves the same as on Windows. Examining memory at that
address value stored in an initialized instance of "va_list" proves that
this is true.

On Linux, for the 64-bit build of the program, sizeof(va_list) returns a
value of 24, and examining an initialized instance of "va_list" in the
debugger [gdb] shows that it is a structured data type, with members
named "gp_offset" , "fp_offset" , "overflow_arg_a rea" and "reg_save_area" .

For both the 32-bit & 64-bit builds of the program on Linux, the
"stdarg.h" header has a typedef that makes "va_list" equivalent to
"__gnuc_va_list ", and another typedef that makes "__gnuc_va_list "
equivalent to "__builtin_va_l ist", which must be defined internally by
gcc itself, rather than being present in any header files.
My best guess at this point is that gcc is defining "__builtin_va_l ist"
for the 64-bit build of the program such that it differs from the
definition of "va_list" used by the the glibc implementations the
various printf() functions.

Google Groups searches of the Usenet archives haven't been turning up
anything useful, and neither has searching the gcc wiki & FAQ.
Has anybody encountered this problem, before? Any info about it would
be helpful, especially any work around or fixes or links to any web
pages that confirm what I think is going wrong.
TIA,

Chuck
Sep 13 '08 #1
1 5548
Sam
Chuck Chopp writes:
My best guess at this point is that gcc is defining "__builtin_va_l ist"
for the 64-bit build of the program such that it differs from the
definition of "va_list" used by the the glibc implementations the
various printf() functions.

Google Groups searches of the Usenet archives haven't been turning up
anything useful, and neither has searching the gcc wiki & FAQ.
Your best guess will, unfortunately, remain only a guess, unless you post
some actual example that demonstrates your question.

What printf use or doesn't use is completely irrelevant. There's nothing in
any standard that requires printf to use stdarg.h-defined facilities to
process its arguments.

Furthermore, I do not see any C++ language-related content, for
comp.lang.c++, here.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEABECAAYFAkj LGogACgkQx9p3GY HlUOLSvgCfQMTvA Q91X2yjtK354tvx Bqv2
QUEAnA2+LhiHzi/AeZiQonhYEzyvQj Nu
=iFUA
-----END PGP SIGNATURE-----

Sep 13 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
7819
by: Michael Cohen | last post by:
Hi, I have to write a function that gets variable number of parameters and pass them to another function (existing). The problem is that the prototype of the function I call has ",..." so I can't just pass it parameters in the format of va_list. The following code does not work since f2 doesn't take arg_list (the prototype of f2 is the same as f1's) void f1(char a ,...)
3
9456
by: shiva | last post by:
hello, just i want to write a program which can take unknown number of integers and sum these numbers using va_list,va_arg... but, i am not able to recognize the last element in series.can u help in this regard. i want a generalized program , i dont want to terminate my series with 0 or any other pre-determined number.
4
2704
by: Egbert Nierop \(MVP for IIS\) | last post by:
Hi, I have a function that has a variable no of arguments (note! function shortened) myfunction(int someID, ...) {
3
4344
by: carvalho.miguel | last post by:
hello, imagine you have a static class method that receives a function pointer, an int with the number of arguments and a variable number of arguments. in that static method you want to call that function (using its pointer) and call it with the same argument list that was passed into the static method.
5
3002
by: shaanxxx | last post by:
i have statements printf("%f",(double)1); /* works fine although i have sent %f for double */ printf("%c",(int)64); /* works fine although i have sent %c for int */ Need your comment on this. As my understanding, when we pass something on variable argument, its type will be promoted . char is promoted to Int . float is promoted to
4
2432
by: mainargv | last post by:
hi How do you rewrite codes with " ... va_list va_start va_etc", so that simple c compiler don't have to deal with them. I have written a simple c->verilog compiler but it can't deal with variable length arguments. How do you rewrite codes with " ... va_list va_start va_etc"? I guess (I'm not too sure) maybe it's easier to rewrite the c code if possible? Modifiying my compiler would mean too much work right now. I have malloc to deal...
4
19246
by: Tor Rustad | last post by:
I have a C program, where I control the error behavior according to context: /* some error handlers */ static void on_error_log (MYSQL *mysql, const char *msg, ...); .... static void on_error_exit (MYSQL *mysql, const char *msg, ...); /* the error function */ static void (*error_fatal) (MYSQL *mysql, const char *msg, ...) =
6
2477
by: junky_fellow | last post by:
Hi, I want to define a function log_file(), that would print the formatted message to stdout if the FILE pointer passed is NULL else print the formatted output to the file corresponding to FILE*. For eg. extern FILE *fp;
5
4666
by: =?ISO-8859-1?Q?Tom=E1s_=D3_h=C9ilidhe?= | last post by:
On Jun 3, 3:23 am, Jesse Ziser <d...@spam.diewrote: The relevant paragraph from the Standard is: ---- Begin Quote ---- The type declared is va_list which is an object type suitable for holding information needed by the macros
45
2012
by: mdh | last post by:
Hi All, The section is titled Variable-length Argument lists. May I ask a question about the use of "macros". To quote K&R. "The standard header <stdarg.hcontains a set of macro definitions that define how to step through an argument list...... The type va_list is used to declare a variable...in minprintf..ap .......The macro va_start initializes ap to point to the first unnamed argument."
0
9454
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10260
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10101
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9906
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8933
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7456
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6712
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5354
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3609
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.