Use of undeclared identifier 'FORCE_TYPE'
-
On 08/01/2018 at 21:27, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 18
Platform: Mac OSX ;
Language(s) : C++ ;---------
Greetings of all! Help with a mistake please! I started studying C ++ and I'm converting a python plugin into C ++. What am I doing wrong?//Connector (Dynamic) Object BaseObject\* suspcon = BaseObject::Alloc(180000011);
suspcon->InsertAfter(cubet);
suspcon->SetName( "Suspension Con " + op->GetName() );
BaseContainer* suspconBC = suspcon->GetDataInstance();
suspconBC->SetData(FORCE_TYPE, 9);FORCE_TYPE = Xcode tells me "Use of undeclared identifier 'FORCE_TYPE'"
All problems are connected with the Connector))) I suspect that I do not understand something about this))) Thanks in advance! -
On 08/01/2018 at 22:40, xxxxxxxx wrote:
Hi evgenyp,
I don't recognise that particular flag. But just a thought, have you included the necessary header file? Looks like it might be dyninteraction.h
WP.
-
On 08/01/2018 at 23:14, xxxxxxxx wrote:
Thanks, I added #include "dynconstraintobject.h" and
#include "dyninteraction.h" everything works! Honestly I did not think that the files will be called so))) Thank you! -
On 09/01/2018 at 02:59, xxxxxxxx wrote:
Hi evgenyp, thanks for writing us.
Beside the missing header needed to fix the undeclared identifier, considering you're moving the first steps in the C++ arena, it's always a recommended practice to check your memory allocation before using any of them.
Specifically i'd suggest to review the code and include:
BaseObject* suspcon = BaseObject::Alloc(180000011); if (suspcon == nullptr) return; // beware to return the "proper" value which your function is expected to return in case something fails suspcon->InsertAfter(cubet); suspcon->SetName("Suspension Con " + op->GetName()); BaseContainer* suspconBC = suspcon->GetDataInstance(); if (suspcon == nullptr) return; // beware to return the "proper" value which your function is expected to return in case something fails suspconBC->SetData(FORCE_TYPE, 9);
Best, Riccardo
-
On 09/01/2018 at 03:05, xxxxxxxx wrote:
Thanks for the remark) But what to return?
-
On 09/01/2018 at 04:13, xxxxxxxx wrote:
Hi evgenyp, actually depends on how you've defined the function/method to which this code belongs to.
Maybe it's worthy to have a look here where functions are briefly explained together with return values.Best, Riccardo