Skip to main content
8-Gravel
Mar 12, 2025 12:06 PM UTC
Question

Object Toolkit - C++ standard and its violations.

Hello Guys. We are struggling a bit with some "not very good" practices that are implemented  by PTC in C++ Object Toolkit API.

 

First is bad&ugly define which collides with default type from standard library. So inside of  ciptype.h at line 68 we have 

 

# define optional

 

which obviously is in conflict with std::optional (see cppreference)

 

Second a bit strange approach we may find in: cipxobj.h and xstring.h both at line 17

 

using namespace std;
 

According to not only CPP reference but to well known best practices it's bad idea:

 

(see cppreference)

The using-directive using namespace std; at any namespace scope introduces every name from the namespace std into the global namespace (since the global namespace is the nearest namespace that contains both std and any user-declared namespace), which may lead to undesirable name collisions. This, and other using directives are generally considered bad practice at file scope of a header file (SF.7: Don’t write using namespace at global scope in a header file).

 

We use Creo Parametric 10.0.5.0  but issue exits there for many years and when C++ 17  standard appeared this become more painful. 

 

Please PTC, remove those lines from your API and make it more modern (and user friendly) 

 

 

 

4 replies

Catalina
Community Moderator
Mar 12, 2025 2:46 PM UTC

Hi @Piotr_64781 

 

Thank you for using the Community!

 

I'd like to suggest posting a product improvement idea here: https://community.ptc.com/t5/Creo-Parametric-Ideas/idb-p/creoparametric

 

Please let me know if you have any questions!

 

Best regards,

Translate
Catalina | PTC Community Moderator
8-Gravel
Mar 19, 2025 7:45 AM UTC

Catalina! Thanks for your hint. Unfortunately your link doesn't work  for me. Can you check if it's ok ? 

Translate
Catalina
Community Moderator
Mar 19, 2025 7:51 AM UTC

Hi Piotr,

 

Sorry about that! One . at the end was the culprit. Should work well now. 😄 

Translate
Catalina | PTC Community Moderator
FV_01
Mar 14, 2025 5:22 PM UTC

good point. my advise is to use pro/toolkit and do not touch otk unless absolutely necessary... 

C++ with pro/toolkit builds clean with C++17 and C++20 even with PTC provided make_install make files with almost no modifications beside changing a switch from c to cpp and specifying c++ target standard. 

Translate