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

Query about " warning parameter names (without types) in functiondeclaration"

Hi All,
I encountered the above error when I tried to expand a macro
as follows:

#define EXPAND(array) int M_ ## array

The problem occurs when we have 'array' itself as a macro:

say EXPAND(ARR(DECL))
where #define DECL _decl
#define ARR(name) arr ## name

So the end result would be M_arr_name

The error goes away when I do:

#define EXPAND(array) int PREPEND_ARR(array)
where
PREPEND_ARR(array) M_ ## array

Can someone explain me why the error is about a 'function declaration'
in this case since we are dealing with MACROS?

Thanks,
/prix
Mar 24 '08 #1
3 4391
On Sun, 23 Mar 2008 18:57:17 -0700 (PDT), prix prad
<ma*****@gmail.comwrote in comp.lang.c:
Hi All,
I encountered the above error when I tried to expand a macro
as follows:

#define EXPAND(array) int M_ ## array

The problem occurs when we have 'array' itself as a macro:

say EXPAND(ARR(DECL))
"say" what?
where #define DECL _decl
#define ARR(name) arr ## name
The end result of what, exactly?
So the end result would be M_arr_name

The error goes away when I do:

#define EXPAND(array) int PREPEND_ARR(array)
where
PREPEND_ARR(array) M_ ## array

Can someone explain me why the error is about a 'function declaration'
in this case since we are dealing with MACROS?
Have you put your macros together in a minimal file and asked your
compiler to show you its preprocessing output? Virtually all
compilers provide this feature?

If so, post the exact contents of that minimal file, all of about
three lines, exactly. Don't use words to tell us about it, show us
the actual macro definitions and expansions. And the output of your
compiler's preprocessor.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://c-faq.com/
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.club.cc.cmu.edu/~ajo/docs/FAQ-acllc.html
Mar 24 '08 #2
prix prad wrote:
I encountered the above error when I tried to expand a macro
as follows:

#define EXPAND(array) int M_ ## array

The problem occurs when we have 'array' itself as a macro:

say EXPAND(ARR(DECL))
where #define DECL _decl
#define ARR(name) arr ## name

So the end result would be M_arr_name

The error goes away when I do:

#define EXPAND(array) int PREPEND_ARR(array)
where
PREPEND_ARR(array) M_ ## array

Can someone explain me why the error is about a 'function declaration'
in this case since we are dealing with MACROS?
...
C preprocessor does not perform preliminary macro expansion for arguments
adjacent to ## operator. For this reason in your first variant of EXPAND the
argument ARR(DECL) is not expanded and

EXPAND(ARR(DECL))

first turns into

int M_ARR(DECL)

and later, after rescanning into the end result

int M_ARR(_decl)

Since 'ARR' get concatenated with 'M_', the preprocessor never gets a chance to
identify that 'ARR' with your 'ARR' macro.

This final result looks like a function declaration to the compiler, which is
why it complains about function declaration.

In your second variant of EXPAND theres no ## in EXPAND and for this reason in

EXPAND(ARR(DECL))

the preliminary macro expansion is applied to the argument ARR(DECL), resulting in

int PREPEND_ARR(arr_decl)

the further rescan turns this into

int M_arr_decl

--
Best regards,
Andrey Tarasevich
Mar 24 '08 #3
Hi Andrey,
Thanks for the lucid explanation.
Hi Jack,

The following is the .c file:
************************************************** ******************
#define DECL _decl
#define ARR(name) arr ## name
#define EXPAND(array) int M_ ## array

main() {
EXPAND(ARR(DECL));
return 1;
}
************************************************** ******************

The following is the 'gcc -E' output:
************************************************** ******************
main() {
int M_ARR(_decl);
return 1;
}
************************************************** ******************

Thanks,
/prix
Mar 25 '08 #4

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

Similar topics

2
by: Liang | last post by:
Hi, I use "defined $r_libs->{$name}" to check first if a key exists in a hash table. But Perl gives a warning WHENEVER the key exists: "Use of uninitialized value". Would u please help to...
7
by: | last post by:
I found similiar issues in MS-KB but nothing that helped me; got the Windows and Office updates from the MS website but that hasn't changed the behavior of this problem, and I don't see anything...
9
by: Mike Bridge | last post by:
I am using MS Access 2003, and I typed in a query in SQL view which was working fine. Now when I open it, it gives me the error "Join expression not supported". Apparently, Access "fixed" it for...
4
by: Ondrej Spanel | last post by:
The code below does not compile with .NET 2003, I get folowing error: w:\c\Pokusy\delegTemplArg\delegTemplArg.cpp(11) : error C2993: 'float' : illegal type for non-type template parameter 'x' ...
5
by: Agnes | last post by:
For my own practices. I like to put "Me". e.g IF Me.txtInvoice.textlength = 0 ....... etc Me.txt.....etc However, Is there any difference (without Me) ?? Thanks
4
by: lcifers | last post by:
Is there a way, through VB.NET, to determine if the user has selected this option? I am writing an application that does some string functions to rename files, and the file names get chopped up if...
10
by: cyber0ne | last post by:
I'm having a bit of trouble adding records to a local .DB file (using a Paradox connection string). I checked the file permissions, and for testing purposes set Everyone to Full access. But it...
11
by: Charles Sullivan | last post by:
I have a number of functions, e.g.: int funct1( int arg1, int arg2, int arg3 ); int funct2( int arg1, int arg2, int arg3 ); int funct3( int arg1, int arg2, int arg3 ); that are called via...
23
by: Rotor | last post by:
In Access 2003 I have a query where it asks the user for two parameter using and pop up. However, I need for the query to return all tasks for the Emp# if TaskType is left blank. I tried "In" in...
4
by: lostlander | last post by:
In ARMCC, and Microsoft C, when i use a function which is never defined or delared, it gives out a warning, not a compiling error? why? (This leads to a bug to my program since I seldom pay much...
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
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: 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
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...
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...

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.