cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

PTC functions do not use const keyword for arguments

ptc-5830787
1-Newbie

PTC functions do not use const keyword for arguments

I'm migrating my TOOLKIT appls (written in C++) to Wildfire2 for Platform
hpux_pa64 and sgi_elf4.
For example on HP the PTC recommend CCFLAGS are:
CC = aCC +DA2.0W -AA -mt

DEFS = -DPRO_MACHINE=20 -DPRO_OS=3 -DUSE_ANSI_IOSTREAMS

CCFLAGS = -z +Z +O2 -Aa +DA2.0W -DPRO_USE_VAR_ARGS -D_HPUX_SOURCE \

-D_POSIX_C_SOURCE=199506L -DNDEBUG +W495

CFLAGS = $(CCFLAGS) $(DEFS) $(INCLDIRS)


I got thousands Compiler warnings because of using const literals, where
non-const variables are expected:
For example:

Warning 829: "MainDmuKos.cpp", line 332 # Implicit conversion of string
literal to 'char *' is deprecated.
proerr = ProMenubarMenuAdd("Add-Ons","DMUKOS
Add-Ons","Help",PRO_B_FALSE,W_MSGFILE);
^^^^^^^^^

Warning 829: "MainDmuKos.cpp", line 332 # Implicit conversion of string
literal to 'char *' is deprecated.
proerr = ProMenubarMenuAdd("Add-Ons","DMUKOS
Add-Ons","Help",PRO_B_FALSE,W_MSGFILE);
^^^^^^^^^^^^^^^^

Warning 829: "MainDmuKos.cpp", line 332 # Implicit conversion of string
literal to 'char *' is deprecated.
proerr = ProMenubarMenuAdd("Add-Ons","DMUKOS
Add-Ons","Help",PRO_B_FALSE,W_MSGFILE);
^^^^^^
The reason is, PTC declares all functions without using the const keyword.
Instead of:
ProError ProMenubarMenuAdd(const char *menu_name,const char* menulabel,const
char *neighbor.....

they declare:

extern ProError ProMenubarMenuAdd ( ProMenuItemName menu_name,
ProMenuItemLabel
untranslated_menu_label,
ProMenuItemName neighbor,
ProBoolean add_after_neighbor,
ProFileName filename );

So, an uggly wordaround would be (in thousands of calls):

strcpy(menu_name,"Add-Ons");
strcpy(menu_label,"DMUKOS Add-Ons");
strcpy(neighbor,"Help");
proerr =
ProMenubarMenuAdd(menu_name,menu_label,neighbor,PRO_B_FALSE,W_MSGFILE);

Any Idea what to do

Mit freundlichen Grüßen / Kind regards

Norbert Schultheis

AUDI AG
I/FP-372
85045 Ingolstadt
Tel. +49 (0)8 41 89-9 03 89
Fax. +49 (0)8 41 89-3 81 15
mailto:norbert.schultheis@audi.de
http://www.audi.com <http: www.audi.com="/>



This thread is inactive and closed by the PTC Community Management Team. If you would like to provide a reply and re-open this thread, please notify the moderator and reference the thread. You may also use "Start a topic" button to ask a new question. Please be sure to include what version of the PTC product you are using so another community member knowledgeable about your version may be able to assist.
0 REPLIES 0
Announcements
Attention: Creo 7.0 Customers
Please consider upgrading
End of Life announcement here.

NEW Creo+ Topics:
PTC Control Center
Creo+ Portal
Real-time Collaboration