473,385 Members | 1,867 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,385 software developers and data experts.

va_list

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

Regards

Oct 11 '07 #1
6 11612
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_Keith) 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.orgwrote:
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_Keith) 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.orgwrote:
>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_Keith) 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.orgwrote:
ramu <ramu....@gmail.comwrites:
On Oct 11, 3:37 pm, Keith Thompson <ks...@mib.orgwrote:
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.orgwrote:
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
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...
3
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...
2
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...
2
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
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...
7
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...
1
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...
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...
6
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...
1
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...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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,...

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.