Welcome to Telelogic Product Support
  Home Downloads Knowledgebase Case Tracking Licensing Help Telelogic Passport
Telelogic Rhapsody (steve huntington)
Decrease font size
Increase font size
Topic Title: modelling int foo(void) is NOT possible ?
Topic Summary:
Created On: 5-Jul-2006 08:15
Status: Read Only
Linear : Threading : Single : Branch
Search Topic Search Topic
Topic Tools Topic Tools
Subscribe to this topic Subscribe to this topic
E-mail this topic to someone. E-mail this topic
Bookmark this topic Bookmark this topic
View similar topics View similar topics
View topic in raw text format. Print this topic.
 5-Jul-2006 08:15
User is offline View Users Profile Print this message


Bernhard Merkle

Posts: 18
Joined: 2-Jun-2005

Hi there

a problem we came across:
It is a common idiom and good codingstyle (btw. some codingstandards require this) to add the "void" into the argument list of a function that takes NO parameter. so say int foo(void); instead of int foo();
Remember: just leaving the parameter list empty results in different behaviour in C/C++ (C means null or any parameter, C++ means null parameter).

However with Rhapsody it seems NOT possible to modell such a operation.
The tool always wants a parameter name. (which is incorrect in this case)
I also searched the properties of CG and CPP_CG but found no way.

any help appreciated,
kind regards,
Bernhard.
Report this to a Moderator Report this to a Moderator
 5-Jul-2006 13:50
User is offline View Users Profile Print this message


Paul Coene

Posts: 10
Joined: 15-Dec-2005

Perhaps not much help, but since you're generating source code does it really matter at all? An empty parameter list in rhapsody is singular in meaning, and one would presume that when you generate code (C or C++) that the generated code will be consistant and functional.
Report this to a Moderator Report this to a Moderator
 6-Jul-2006 17:48
User is offline View Users Profile Print this message


Simon Morrish

Posts: 127
Joined: 17-May-2005

Hi Bernhard

(First, just a clarification: RiCpp does use void; it's just RiC that has this issue.)

I don't know of any property that can control this behaviour, and I tend to agree with Paul's view on this. However, I do have a suggested solution if you really need your voids

[list=1]
[*]Create a type to define (eg.) EMPTY as nothing.
[*]Add parameters with the type set to void and the name set to EMPTY.
[/list]

The generated code would be:

[CODE]/*#[ ignore */
#define EMPTY
/*#]*/

...

/*## operation foo(void) */
int foo(void EMPTY);[/CODE]

I know it's a bit of a hack, but...

best regards,
Simon

-------------------------
Simon Morrish
simon.morrish@eu.panasonic.com
http://panasonic.co.uk
Panasonic ideas for life
Report this to a Moderator Report this to a Moderator
 12-Jul-2006 13:12
User is offline View Users Profile Print this message


Bernhard Merkle

Posts: 18
Joined: 2-Jun-2005

Hi Simon,

thanks for your reply, but I have this issue with RiC AND RiCPP. :confused:
I have to specify parameternames for void in both systems, C and C++.
I do not know if UML requires this (if a parameter NAME is required)
but the codegenerator should ignore this IMO.

kind regards,
Bernhard.
Report this to a Moderator Report this to a Moderator
 13-Jul-2006 07:39
User is offline View Users Profile Print this message


Simon Morrish

Posts: 127
Joined: 17-May-2005

Hi Bernhard

[QUOTE=Bernhard.Merkle@sick.de]I have to specify parameternames for void in both systems, C and C++.[/QUOTE]
You're right; this is true. But if you specify no parameter, then RiC (v6.1MR1) generates:
[CODE]int foo()[/CODE]
while RiCpp generates:
[CODE]int foo(void)[/CODE]
Hopefully you see the same behaviour? For RiC, you could use my "hack" (see my previous post) to force a void, but ideally Rhapsody should be configurable to generate void-or-no-void when no parameter is specified. Perhaps it is and I just don't know it! Anyone? :confused:

best regards,
Simon

-------------------------
Simon Morrish
simon.morrish@eu.panasonic.com
http://panasonic.co.uk
Panasonic ideas for life
Report this to a Moderator Report this to a Moderator
 14-Jul-2006 06:31
User is offline View Users Profile Print this message


Beery Holstein

Posts: 105
Joined: 11-Jun-2004

Hello,

Try C_CG:Configuration:EmptyArgumentListName.

The EmptyArgumentListName (under C_ and C_CG::Configuration) specifies the string generated for the argument list when an operation has no arguments. For example, if you set this value to ?void?, for an operation foo that has no arguments, Rhapsody generates the following code:
void noargFunc(void);

Best Regards,
Beery
Report this to a Moderator Report this to a Moderator
 14-Jul-2006 06:37
User is offline View Users Profile Print this message


Bernhard Merkle

Posts: 18
Joined: 2-Jun-2005

[QUOTE]
But if you specify no parameter, then RiC (v6.1MR1) generates:
[CODE]int foo()[/CODE]
while RiCpp generates:
[CODE]int foo(void)[/CODE]

Hopefully you see the same behaviour?
[/QUOTE]

I have Rhapsody 6.2 here, and I do NOT get int foo(void) in C++
so I do NOT see the same behaviour (unfortunately)

Instead I get int foo() in C++ !?? :confused:

Have you changed/overwritten any CG/CPP_CG properties ?
Report this to a Moderator Report this to a Moderator
 14-Jul-2006 09:10
User is offline View Users Profile Print this message


Beery Holstein

Posts: 105
Joined: 11-Jun-2004

Did you try to overide the property in the configuration level?

Thanks,
Beery
Report this to a Moderator Report this to a Moderator
 14-Jul-2006 12:06
User is offline View Users Profile Print this message


Bernhard Merkle

Posts: 18
Joined: 2-Jun-2005

Hi Beery,

great this is exactly what i was looking for.

thanks for your help,
Bernhard.
Report this to a Moderator Report this to a Moderator
Statistics
20925 users are registered to the Telelogic Rhapsody forum.
There are currently 1 users logged in.
You have posted 0 messages to this forum. 0 overall.

FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.