473,807 Members | 2,851 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

va_list

Hi,
Can we intialize va_list to NULL?
ie. va_list = NULL

Regards

Oct 11 '07 #1
6 11684
ramu <ra******@gmail .comwrites:
Can we intialize va_list to NULL?
ie. va_list = NULL
Probably not. va_list is "an object type suitable for holding
information needed by the macros va_start, va_arg, va_end, and
va_copy"; it's unlikely to be a pointer type.

What are you trying to accomplish?

--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Oct 11 '07 #2
On Thu, 11 Oct 2007 12:37:07 -0700, Keith Thompson wrote:
ramu <ra******@gmail .comwrites:
> Can we intialize va_list to NULL?
ie. va_list = NULL

Probably not. va_list is "an object type suitable for holding
information needed by the macros va_start, va_arg, va_end, and va_copy";
it's unlikely to be a pointer type.
I have one implementation where va_list is a typedef for char *, and know
of one where it's a typedef for void *. Also, implementations are allowed
to define NULL as 0, which is a valid initialiser for all scalar types. I
wouldn't say we can "probably" not initialise a va_list to NULL, just
that it's not portable and a bad idea even on the systems that do allow
it.
Oct 11 '07 #3
On Oct 11, 3:37 pm, Keith Thompson <ks...@mib.orgw rote:
ramu <ramu....@gmail .comwrites:
Can we intialize va_list to NULL?
ie. va_list = NULL

Probably not. va_list is "an object type suitable for holding
information needed by the macros va_start, va_arg, va_end, and
va_copy"; it's unlikely to be a pointer type.

What are you trying to accomplish?

--
Keith Thompson (The_Other_Keit h) ks...@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Miniss

Sorry. I meant va_list ap=NULL;
Not va_list = NULL;

Oct 11 '07 #4
ramu <ra******@gmail .comwrites:
On Oct 11, 3:37 pm, Keith Thompson <ks...@mib.orgw rote:
>ramu <ramu....@gmail .comwrites:
Can we intialize va_list to NULL?
ie. va_list = NULL

Probably not. va_list is "an object type suitable for holding
information needed by the macros va_start, va_arg, va_end, and
va_copy"; it's unlikely to be a pointer type.

What are you trying to accomplish?

Sorry. I meant va_list ap=NULL;
Not va_list = NULL;
Please don't quote signatures (the stuff following the "-- " line)
unless you're actually commenting on them.

I assumed that was what you meant; I actually missed the fact that you
assigned a value to a type rather than to a variable.

But again, va_list is not necessarily a pointer type, and assigning a
null value to a va_list object, as far as I can tell, doesn't make any
sense.

And again, what are you trying to accomplish?

--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Oct 11 '07 #5
On Oct 12, 2:39 am, Keith Thompson <ks...@mib.orgw rote:
ramu <ramu....@gmail .comwrites:
On Oct 11, 3:37 pm, Keith Thompson <ks...@mib.orgw rote:
ramu <ramu....@gmail .comwrites:
Can we intialize va_list to NULL?
ie. va_list = NULL
Probably not. va_list is "an object type suitable for holding
information needed by the macros va_start, va_arg, va_end, and
va_copy"; it's unlikely to be a pointer type.
What are you trying to accomplish?
Sorry. I meant va_list ap=NULL;
Not va_list = NULL;

Please don't quote signatures (the stuff following the "-- " line)
unless you're actually commenting on them.

I assumed that was what you meant; I actually missed the fact that you
assigned a value to a type rather than to a variable.

But again, va_list is not necessarily a pointer type, and assigning a
null value to a va_list object, as far as I can tell, doesn't make any
sense.

And again, what are you trying to accomplish?
Am getting Lint warning saying that variable is not initialized.
So am trying to initialize ap to NULL.
Oct 12 '07 #6
ramu <ramu....@gmail .comwrote:
Keith Thompson <ks...@mib.orgw rote:
Can we intialize va_list to NULL?
... va_list is not necessarily a pointer type, and
assigning a null value to a va_list object, as far as I
can tell, doesn't make any sense.

And again, what are you trying to accomplish?

Am getting Lint warning saying that variable is not
initialized. So am trying to initialize ap to NULL.
va_list ap = { 0 };

You can initialise _any_ object with { 0 }. However, if you're
just doing this to silence one warning, realise that applying
a fix may simply raise an alternative warning.

Apart from fixing actual errors, you shouldn't be letting
implementations (or tools thereof) dictate how you write
your code.

Too many programmers fall into the trap of adding needless
casts because a compiler is beeping at them without it.
Because they haven't checked whether there is an actual
problem with the code, they inadvertently add one thinking
that if the compiler has stopped complaining, the code
must be correct.

--
Peter

Oct 12 '07 #7

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

Similar topics

6
3697
by: Peter | last post by:
-------------------------------------------------------------------------------- Hi, I was wondering if we can create a va_list by adding objects in the va_list instead of passing in the parameter preceding first optional argument? In another words, I want to create a va_list in a similar manner as creating an array. The reason is I want to use FormatMessage() in my program where it
3
16782
by: Douwe | last post by:
I try to build my own version of printf which just passes all arguments to the original printf. As long as I keep it with the single argument version everything is fine. But their is also a version which uses the "..." as the last parameter how can I pass them to the orignal printf ? void myprintf(char *txt, ...) printf(txt, ???????); }
2
3348
by: Joerg Schoen | last post by:
Hi folks! I have a function that gets a 'va_list'. I am passing the 'va_list' two times to a function like 'vprintf' to print it out. I thought that this was portable until I came across a platform (AS/400) where it fails: The 'va_list' is actually defined as some some kind of an array, so passing it happens by *reference*: The first user will destroy it and the second
2
2542
by: j0mbolar | last post by:
given this example: void bar(const char *fmt, ...) { va_list ap; va_start(ap, fmt); baz(fmt, ap); va_end(ap);
11
3077
by: thierrydollar | last post by:
Hi, I have written a very simple program using variable arguments calls and I get strange things that I cannot explain. I have one function (add) that displays two parameters. It works well when I call it directly. Now I have a second function (set) that also calls add. But this doesn't
7
2865
by: Flash Gordon | last post by:
Reading the standard, va_list is an object type (, so I believe the following should be possible: #include <stdarg.h> void foo(va_list *arg) { /* do some stuff which conditionally might read parameters off arg */ }
1
9477
by: skillzero | last post by:
Is there a portable way to pass a va_list as a parameter to another function taking a variable argument list? I have a function that takes a printf-like format string and I'd like to use something like %V to pass in another format string and a va_list to allow nesting. It happens to work on my compiler, but I wasn't sure if it's portable to use va_list's as parameters to a variable argument function because va_list isn't always just a...
5
4670
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
6
4069
by: Laurent Deniau | last post by:
When I compile the code below with gcc -std=c99 -W -Wall -pedantic -O3 -Winline, it reports the following: variadic.c: In function ‘fv’: variadic.c:12: warning: function ‘fv’ can never be inlined because it uses variable argument lists variadic.c: In function ‘vf’: variadic.c:12: warning: inlining failed in call to ‘fv’: function not inlinable variadic.c:27: warning: called from here
1
5552
by: Chuck Chopp | last post by:
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
0
9720
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9599
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
10626
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
10372
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...
1
7650
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
6879
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
5685
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4330
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3011
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.