473,399 Members | 3,656 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,399 software developers and data experts.

Passing commas into macros

How do I pass text that contains a comma into a macro? For example, I
have

#define ATTRIBUTE(name,type) ...

and I want to do

ATTRIBUTE(transitions, map<int,int>);

However, the last comma is being interpretted as the macro argument
delimiter, and I get the error

macro "ATTRIBUTE" passed 3 arguments, but takes just 2

Help?
Jul 22 '05 #1
3 2962
Grey Plastic wrote:
How do I pass text that contains a comma into a macro? For example, I
have

#define ATTRIBUTE(name,type) ...

and I want to do

ATTRIBUTE(transitions, map<int,int>);
Try

ATTRIBUTE(transitions, (map<int,int>))

Or, worst case

typedef map<int,int> map_int_int;
ATTRIBUTE(transitions, map_int_int)


However, the last comma is being interpretted as the macro argument
delimiter, and I get the error

macro "ATTRIBUTE" passed 3 arguments, but takes just 2

Help?


Jul 22 '05 #2
Grey Plastic wrote:
How do I pass text that contains a comma into a macro? For example, I
have

#define ATTRIBUTE(name,type) ...

and I want to do

ATTRIBUTE(transitions, map<int,int>);

However, the last comma is being interpretted as the macro argument
delimiter, and I get the error

macro "ATTRIBUTE" passed 3 arguments, but takes just 2
...


Use typedef-name for the type

typedef map<int,int> TMapIntInt;
ATTRIBUTE(transitions, TMapIntInt);

--
Best regards,
Andrey Tarasevich

Jul 22 '05 #3
gr*********@hotmail.com (Grey Plastic) wrote:
# How do I pass text that contains a comma into a macro? For example, I
# have
#
# #define ATTRIBUTE(name,type) ...
#
# and I want to do
#
# ATTRIBUTE(transitions, map<int,int>);
#
# However, the last comma is being interpretted as the macro argument
# delimiter, and I get the error

In C, many of these kinds of constructs can be parenthesised
and avoid irritating cpp. If in C++ (map<int,int>) is equivalent to
map<int,int>, then you can use ATTRIBUTE(transitions, (map<int,int>));

--
Derk Gwen http://derkgwen.250free.com/html/index.html
So....that would make Bethany part black?
Jul 22 '05 #4

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

Similar topics

3
by: Bolin | last post by:
I am using a macro to define template functions that look the same except for a type. However when the return type it a template class with several template arguments (say, A<T1, T2>) then the...
10
by: Resant | last post by:
I have a query : Exec 'Select * From Receiving Where Code In (' + @pCode + ')' @pCode will contain more than one string parameter, eg : A1, A2, A3 How can i write that parameters, I try use :...
22
by: ineedyourluvin1 | last post by:
Hello all! I've been looking for a way to strip characters from strings such as a comma. This would be great for using a comma as a delimiter. I show you what I have right now. ...
7
by: AES | last post by:
Encountered a URL containing a comma the other day -- the first time I've ever noticed that, so far as I can recall. It worked fine, however, and I gather commas are legal in URLs. Out of...
27
by: Peter Ammon | last post by:
My code obfuscator gave me this: char buff; to which gcc retorted: "ISO C90 forbids variable-size array 'buff'" and checking the standard, it appears that commas are indeed forbidden...
3
by: Robert Scheer | last post by:
Hi. I have a regularexpression validator control on a page. This regular expression validates a textbox to accept only numbers and commas: validationexpression="*" I am trying to modify this...
4
by: striker | last post by:
I have a comma delimited text file that has multiple instances of multiple commas. Each file will contain approximatley 300 lines. For example: one, two, three,,,,four,five,,,,six one, two,...
0
by: skinnybloke | last post by:
Hi I have written 3 seperate macros in access to run 3 queries to export 3 .xls files. Sometimes I will need to run them individually. Sometimes I will need to run them all together...
7
by: MattyWix | last post by:
Hi, How can I pass a semicolon or a comma as a macro argument. I wish to build an expression that in some cases has a comma - eg building a list of members for a structure, but in other...
3
by: hg | last post by:
I have a function called logprintf that take a printf-like syntax. On top of that I want to implement a debug-printf function which calls logprintf but prefix the information using a string: ...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...

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.