473,249 Members | 1,719 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,249 software developers and data experts.

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_area" 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_list", 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_list"
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 5468
Sam
Chuck Chopp writes:
My best guess at this point is that gcc is defining "__builtin_va_list"
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)

iEYEABECAAYFAkjLGogACgkQx9p3GYHlUOLSvgCfQMTvAQ91X2 yjtK354tvxBqv2
QUEAnA2+LhiHzi/AeZiQonhYEzyvQjNu
=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
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...
3
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...
4
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
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...
5
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...
4
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...
4
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...
6
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...
5
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...
45
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...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

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.