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

object-like macro used like function-like macro

Hi all,

Is this valid? I do not find the case in the standard:

void foo( int ) {}

#define FOO foo

int main()
{
FOO(0);
return 0;
}

Kind regards,
Patrick
Mar 14 '06 #1
5 1982
Patrick Kowalzick wrote:
Is this valid? I do not find the case in the standard:

void foo( int ) {}

#define FOO foo

int main()
{
FOO(0);
return 0;
}


I am fairly perplexed as to your statement about not finding this "case in
the standard". Did you expect to find precisely this code or any other
explanation to make this legal or not? Where in the Standard did you
look? 'FOO' is replaced with 'foo' in the code _following_ the definition
of 'FOO' macro. Once the preprocessor is done with the code, you get

"void foo(int){}int main(){foo(0);return 0;}"

(I left the spaces where needed to separate the preprocessor tokens).
What's invalid about that code?

And what is "object-like macro" you're referring to in your subject line?

V
--
Please remove capital As from my address when replying by mail
Mar 14 '06 #2
> Hi all,

Is this valid? I do not find the case in the standard:

void foo( int ) {}

#define FOO foo

int main()
{
FOO(0);
return 0;
}


ARGH. I found my problem. Sorry, really stupid. It was something like:

#ifdef THIS_IS_NOT_DEFINED
#define FOO foo
#else
#define FOO()
#endif

- rather ugly.

Thanks,
Patrick
Mar 14 '06 #3
Hello Victor,
I am fairly perplexed as to your statement about not finding this "case in
the standard".
Sorry to be unprecise. What I do not find is, how a macro expansion is
carried out. And even if my problem was a rather stupid one (see other
post), I do not find the necessary paragraphs for the expansion rules.
Where in the Standard did you look?
Chapter 16.
And what is "object-like macro" you're referring to in your subject line?
Object-like and function-like macro is mentioned in 16.3p2,3.

Thanks,
Patrick
V
--
Please remove capital As from my address when replying by mail

Mar 14 '06 #4
Patrick Kowalzick wrote:
Hello Victor,

I am fairly perplexed as to your statement about not finding this "case in
the standard".

Sorry to be unprecise. What I do not find is, how a macro expansion is
carried out. And even if my problem was a rather stupid one (see other
post), I do not find the necessary paragraphs for the expansion rules.


16.3/8 and 16.3/9. I am surprised you didn't find it, considering that
you read 16.3 apparently quite carefully.
Where in the Standard did you look?

Chapter 16.


Yep, it's there alright.
And what is "object-like macro" you're referring to in your subject line?

Object-like and function-like macro is mentioned in 16.3p2,3.


Gotcha. I never used those terms before and they'd slipped off my mind,
obviously.

V
--
Please remove capital As from my address when replying by mail
Mar 14 '06 #5
>>>I am fairly perplexed as to your statement about not finding this "case
in
the standard".

Sorry to be unprecise. What I do not find is, how a macro expansion is
carried out. And even if my problem was a rather stupid one (see other
post), I do not find the necessary paragraphs for the expansion rules.


16.3/8 and 16.3/9. I am surprised you didn't find it, considering that
you read 16.3 apparently quite carefully.


Yes, me too. The reason is quite easy. I was a little bit irritated by the
wording:

-macro expansion (16p4)
-macro replacement (16.3, 16.3.8, 16.3.9,..)
-macro redefinition (16.3.2, 16.3.3)

In fact it is intuitive :).

Regards,
Patrick
Mar 14 '06 #6

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

Similar topics

2
by: Timo J | last post by:
Hi - Im sitting and trying to understand this OOP - and need to create a class wich can do the following.. ShowBlocks() - Displays the data wich is inside it - If empty creates a form wich sends...
0
by: VBProgrammer | last post by:
I get the following error when I do an Excel.Workbooks.Open. This error occurs on some PCs but not others. The error and associated code are below. Thanks in advanc Error...
9
by: Keith Rowe | last post by:
Hello, I am trying to reference a Shockwave Flash Object on a vb code behind page in an ASP.NET project and I receive the following error: Guid should contain 32 digits with 4 dashes...
11
by: C++fan | last post by:
Suppose that I define the following class: class example_class{ public: example_class(); void funtion_1(); void function_2(); protected:
12
by: Mark | last post by:
I have a C# add in that inserts a custom active x control into a worksheet. Once the object is inserted i can locate the object through both Shapes and Worksheet.OLEObjects. What I can't do is...
3
by: Steve Lutz | last post by:
Hi All, I have a Windows Service that runs well. The service hosts a remote object. The purpose of the object is so that I can "peak" into the service to see what it's doing. I wrote a small...
6
by: David Whitchurch-Bennett | last post by:
Hi There, I have created a very simple web user control, containing only a combo box. I have created a class which contains some private object variables, for example... Private _anObject as...
4
by: gg9h0st | last post by:
i worte a simple code below. ------------------------------------------------------------------------------------ #include "stdafx.h" class Object { public: int a;
1
by: winston.heng | last post by:
Hi, Thanks for reading this posting. I have been cracking my head on solving the infinite loop when i call the following section code. Any help or advise is greatly appreciated =D Thanks in...
11
by: Andrus | last post by:
I'm implementing entity object which should populate its properties from database when property is first referenced. In RDL reports I use object properties like MyObject.MyProperty MyObject...
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.