473,785 Members | 2,290 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2005
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);r eturn 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_DEF INED
#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
2337
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 the info back to the Object, wich show the stuff.. AddBlock( $type ) - Creates an empty blok - wich is addet to a blocks area object...( Or somethin like it ) Store() - safes the info into a file, and updates mySQL... I have figured out most...
0
1730
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 System.NullReferenceException: Object reference not set to an instance of an object at Excel.Workbooks.Open(String Filename, Object UpdateLinks, Object ReadOnly, Object Format, Object Password, Object WriteResPassword, Object IgnoreReadOnlyRecommended, Object Origin,...
9
8605
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 (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx). On the aspx page I have the object tag as follows:
11
3101
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
6090
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 figure out how to use the object programatically. I added a reference to the object in the Visual Studio project by importing the object OCX. The reference shows
3
19714
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 Windows Application that connects to the remote object and prints out status information. Everything works fine when I first start the service. However, after some period, when I attempt to connect to the remote object, I get "Requested Service not...
6
1517
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 Object Public Property anObject() As Object Get
4
1978
by: gg9h0st | last post by:
i worte a simple code below. ------------------------------------------------------------------------------------ #include "stdafx.h" class Object { public: int a;
1
8770
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 advance. Cheers!
11
3971
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 is instance of MyEntity class. There is no MyProperty property in MyObject at design time.
0
10350
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
10157
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
10097
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
9957
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...
0
6742
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
5386
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
5518
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3658
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2887
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.