473,386 Members | 2,129 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,386 software developers and data experts.

Some problem on macro declaration in C again

Before I thought C is simple and convient , but now I dont think
so.There is really some ugly thing in C.Today I see some macro
declaration like this:

void va_end (va_list); /* Defined in gnulib */
#define va_end(AP)

Even if we dont consider what va_end do,but doesnt it cause some name
confliction as a result of its two appearances?

Mar 10 '06 #1
3 1964
zh*********@gmail.com schrieb:
Before I thought C is simple and convient , but now I dont think
so.There is really some ugly thing in C.Today I see some macro
declaration like this:

void va_end (va_list); /* Defined in gnulib */
#define va_end(AP)

Even if we dont consider what va_end do,but doesnt it cause some name
confliction as a result of its two appearances?


1) You are looking at the so-called implementation -- it is perfectly
free to do whatever it wants however it wants as long as it provides
you with the language and library facilities you are expecting.
2) You did not provide enough context, so it is perfectly possible
that these two "definitions" are mutually exclusive (e.g. by
conditional compilation).
3) OT here: The "gnulib" is not written in standard C. Not even the
parts which could have been written in standard C. They usually use
a language following the gnu89 or gnu99 standard.

Cheers
Michael
--
E-Mail: Mine is an /at/ gmx /dot/ de address.
Mar 10 '06 #2
2) You did not provide enough context, so it is perfectly possible
that these two "definitions" are mutually exclusive (e.g. by
conditional compilation). Actually these codes come from early Linux's kernel ,version 0.11.
And I am sure that there's no other codes related to these two lines.
O,wait,there's also a invoking statement as below:

char * s;
va_end(s);

I dont think they can help something.
Absolutely,there's no conditional comilation statements.
3) OT here: The "gnulib" is not written in standard C. Not even the
parts which could have been written in standard C. They usually use
a language following the gnu89 or gnu99 standard.

The files are compiled with gcc,version about 1.4.x. I cant remember
clearly.
I dont know if it is compatabe with standard C.If not,maybe that can
explain.
--
http://www.mozilla.net.cn/spread/ima...rediscover.png

Mar 10 '06 #3
"zh*********@gmail.com" <zh*********@gmail.com> writes:
Before I thought C is simple and convient , but now I dont think
so.There is really some ugly thing in C.Today I see some macro
declaration like this:

void va_end (va_list); /* Defined in gnulib */
#define va_end(AP)

Even if we dont consider what va_end do,but doesnt it cause some name
confliction as a result of its two appearances?


Many times, a library will provide both a function (as required by the
standard), and a function-like macro that does the same thing
(explicitly allowed by the Standard). In the case of va_end(), the
Standard specifically allows va_end() to be either a function /or/ a
macro /or/ both.

With code like the above, if you call va_end(ap), then you'll invoke
the macro, which apparently does nothing (but still must be provided,
per the Standard). If you call (va_end)(ap), you'll be guaranteed to
get the function (which probably also does nothing, in your
implementation).

However, (va_end)(ap) is explicitly not supported by the Standard, so
I don't really know why they bothered to provide a real function. For
other Standard functions that are allowed to be macros, though, that
style is the usual way to ensure that you really call a function, not
invoke a macro.

-Micah
Mar 10 '06 #4

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

Similar topics

0
by: Jim Caddy | last post by:
Hi all, I have an Autokeys Macro that's all in a sudden not working in access 2000 when pressing the key combinations. Open up the database in Access 2002 and the macro works, reopen the...
193
by: Michael B. | last post by:
I was just thinking about this, specifically wondering if there's any features that the C specification currently lacks, and which may be included in some future standardization. Of course, I...
3
by: junky_fellow | last post by:
Consider the following piece of code: $ cat a.c extern int func(int); #define func(i) (i+i) int main(void) { (func)(10); } On preprocessing the above code,
17
by: fctk | last post by:
some other doubts: 1) K&R, p50, 2.10: "if expr1 and expr2 are expressions, then expr1 op= expr2 is equivalent to expr1 = (expr1) op (expr2) except that expr1 is computed only once."
2
by: srinu.fsl | last post by:
there's a MACRO call : MACRO1(cnf) and its expansion is : #define MACRO1(cnf) (((cnf) != TRUE)? (CLEANUP(FAIL)):(err = SUCCESS)); #define CLEANUP(a)
2
by: dis_is_eagle | last post by:
Hi.If I define a macro which contains a variable declaration,then during expansion the declaration will not be placed at the beginning of the program,but somwhere within it.How can I overcome it? ...
20
by: rkk | last post by:
Hi, Is there an equivalent typeof macro/method to determine the type of a variable in runtime & most importantly that works well with most known C compilers? gcc compiler supports typeof()...
0
by: =?Utf-8?B?TGV0emRvXzF0?= | last post by:
I'd like to create a Macro that will sort some raw data, apprx 20k lines, remove some lines based upon a condition in a certain column. Then copy this data into a new spreadsheet and sort the ...
36
by: sh.vipin | last post by:
how to make large macro paste the code as it is Problem Explanation '-- For example in the program below /* a.c - starts here */ #define DECL_VARS() \ unsigned int a0;\ unsigned int a1;\...
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: 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?
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
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.