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

what's the meaning of the macro

I had thinked about the implements of variable argument for a long
time.
But I only know a little about it on the following macro.
Could you please explain it for me?
more detail.Thanks very much.

typedef char *va_list;
275 #endif /* _VALIST */
276
277 /*
278 * Storage alignment properties
279 */
280
281 #define _AUPBND (sizeof (acpi_native_int) - 1)
282 #define _ADNBND (sizeof (acpi_native_int) - 1)
283
284 /*
285 * Variable argument list macro definitions
286 */
287
288 #define _bnd(X, bnd) (((sizeof (X)) + (bnd)) & (~(bnd)))
289 #define va_arg(ap, T) (*(T *)(((ap) += (_bnd (T,
_AUPBND))) - (_bnd (T,_ADNBND))))
290 #define va_end(ap) (void) 0
291 #define va_start(ap, A) (void) ((ap) = (((char *) &(A)) +
(_bnd (A,_AUPBND))))
292

Sep 11 '06 #1
1 2140
DaVinci wrote:
I had thinked about the implements of variable argument for a long
time.
But I only know a little about it on the following macro.
Could you please explain it for me?
more detail.Thanks very much.

typedef char *va_list;
275 #endif /* _VALIST */
276
277 /*
278 * Storage alignment properties
279 */
280
281 #define _AUPBND (sizeof (acpi_native_int) - 1)
282 #define _ADNBND (sizeof (acpi_native_int) - 1)
283
284 /*
285 * Variable argument list macro definitions
286 */
287
288 #define _bnd(X, bnd) (((sizeof (X)) + (bnd)) & (~(bnd)))
289 #define va_arg(ap, T) (*(T *)(((ap) += (_bnd (T,
_AUPBND))) - (_bnd (T,_ADNBND))))
290 #define va_end(ap) (void) 0
291 #define va_start(ap, A) (void) ((ap) = (((char *) &(A)) +
(_bnd (A,_AUPBND))))
292
It's internal implementation magic, playing with implementation-dependant
properties of the addresses of the arguments to variable-argument
functions.

Unless you /need/ to know what it all means, likely best to
stay away from it. Otherwise it may tempt you to rely on it.

(`va_start` finds the address of the first variable argument,
`va_arg` returns the item at the current address and advances,
`va_end` tidies up if that's necessary.)

--
Chris "seeker" Dollin
"The path to the web becomes deeper and wider" - October Project

Sep 11 '06 #2

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

Similar topics

220
by: Brandon J. Van Every | last post by:
What's better about Ruby than Python? I'm sure there's something. What is it? This is not a troll. I'm language shopping and I want people's answers. I don't know beans about Ruby or have...
23
by: herrcho | last post by:
What's the difference between STDIN and Keyboard buffer ? when i get char through scanf, i type in some characters and press enter, then, where do the characters go ? to STDIN or Keyboard...
9
by: Qiao Jian | last post by:
I am new to c. Today I just read an h file within which there is statements: #ifndef _RANDOM_H #define _RANDOM_H So what is the meaning or purpose of this statement? When should I use such...
4
by: Garry Freemyer | last post by:
I'm trying to convert this macro to a c# function but I have a big problem. It's on the LEFT side of an assignment statement and I am extremely flustered over this one because I'm a little rusty...
22
by: nick | last post by:
i do not know what is the use of (e.g. void *pt), when will use it. thanks!
16
by: Abhishek | last post by:
why do I see that in most C programs, pointers in functions are accepted as: int func(int i,(void *)p) where p is a pointer or an address which is passed from the place where it is called. what...
17
by: zhangyue.zl | last post by:
static void (DEVICE_REQUEST)(void); What does this line declare in C? I am always meeting some codes like this,but I have never learnt that before. It looks like a declaration of a function,but...
10
by: Thierry Lam | last post by:
What does the following macro mean, especially the << sign: #define hello(x) (( int64 ) floor( (double) x ) << 32) Thanks Thierry
6
by: raghu | last post by:
Hello This is raghu. And I want to know about the meaning of the statement given below log_txt( __FILE__, __LINE__, ##argList); in above statement what does FILE ,LINE ##argList mean. I want to...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...

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.