Click here to Skip to main content
15,887,843 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Here is a example of a define statement in the my code shown below under heading Definition. It is used as shown further below code under heading Usage. Here are my questions if you can help.
1) I am guessing '>CMAR_ENTRY_CHILD_REF2' is replaced by '(mMar, parenthesizedArgList)' wherever I use it. Is this an accurate statement?
2) if above statement 1) is correct, the function does not have a name? I havent seen that in C++ before. Can you define a function without a name?
3) What is the '\' in the code right after the code 'parenthesizedArgList' and after 'parenthesizedArgList)\{'?
4) If you have any links that explains below, please let me know. It is hard to google search this.

//Definition
#define CMAR_ENTRY_CHILD_REF2(mMar, parenthesizedArgList)\
	{\  
            string name=""; 
            //More code below
    };

//Usage
CMAR_ENTRY_CHILD_REF2(m_array[0], (strName, GetSafeArraye(curve)));


What I have tried:

i have looked online. I understand basic define statements for now.
Posted
Updated 16-Feb-18 5:21am
v2
Comments
Richard MacCutchan 15-Feb-18 13:02pm    
I don't quite understand what you are trying to achieve with this, but it is not the best way to write C++ functions.
nitrous_007 15-Feb-18 15:05pm    
Sorry when I say it was 'my code' I meant company code. Its not my code. I see about a 100 functions defined like above. I am just trying to understand what it means.

Also sorry about the double post. I tried to post and codeproject gave me an error and I though my original post didnt post. I deleted the older post. Codeproject seems slow and a little buggy. When i try to delete my original post, it kept spinning. I had to refresh the page manually to see that post was deleted. My internet and browser(Chrome) are good and dont have any issues at work before.
Richard MacCutchan 16-Feb-18 4:22am    
If you don't understand that code then it is unlikely that I will be able to. Especially since most of the code and the actual usage is missing.

As to your problem posting, CodeProject usually has something in excess of 50,000 users online so occasionally it can be a little slow in responding. That does not mean it is buggy.
nitrous_007 16-Feb-18 8:11am    
I understand it now. It was just #define identifier ( identifieropt,...,identifieropt)token-stringopt in the link you posted.

So in 1 occasion, page crashed. Other occasion page was hanging for 2 minutes. Its probably not a bug, just a resource problem.

 
Share this answer
 
Richard is correct by linking you to the documentation.

I would advise you to NOT use such macros, because they lead to trouble and make code unreadable, buggy, unstable and problematic to debug. It is better to declare such stuff in a class and some functions.

Staying away from trouble is bullet proof success strategy ;-)
 
Share this answer
 
Comments
nitrous_007 19-Feb-18 16:51pm    
Thanks. I will let one of the senior developers know and get his opinion. I hate defines generally unless they are simple. I have seen some of the cases where they can go wrong. Its not my code but i have to take care of this code for the time being.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900