Skip to main content
8-Gravel
March 12, 2025
Question

Object Toolkit - C++ standard and its violations.

  • March 12, 2025
  • 2 replies
  • 1085 views

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) 

 

 

 

2 replies

Catalina
Community Moderator
March 12, 2025

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,

Catalina | PTC Community Moderator
8-Gravel
March 19, 2025

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

Catalina
Community Moderator
March 19, 2025

Hi Piotr,

 

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

Catalina | PTC Community Moderator
March 14, 2025

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.