473,795 Members | 2,805 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1986
zh*********@gma il.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 "definition s" 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 "definition s" 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,ther e'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*********@gm ail.com" <zh*********@gm ail.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
1680
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 database in Access 2000 again and the macro doesn't work again. It will work by double clicking the macro in the database window. Created a new database in Access 2000 and made a Autokeys macro for testing, this didn't work either. Opened the new...
193
9653
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 speak only of features in the spirit of C; something like object-orientation, though a nice feature, does not belong in C. Something like being able to #define a #define would be very handy, though, e.g: #define DECLARE_FOO(bar) #define...
3
1378
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
1760
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
3495
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
6650
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? Eric
20
21778
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() macro, but the same code is not getting compiled in solaris forte compiler and in microsoft VS 2003 compiler. I tried something like below:
0
2055
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 data again and delete the unwanted data and repeat few more times in new sheets. End product will be apprximately 7 or 8 sheets - 1 for Active Customers, Inactive Customers, Pending Installs, Etc... I'm getting hung up I believe with naming...
36
2567
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;\ unsigned int a2;\
0
10443
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
10216
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
10165
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10002
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7543
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
6783
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
5437
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5565
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2921
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.