Custom joints changes and GCC

Report any bugs here and we'll post fixes

Moderators: Sascha Willems, Thomas

Custom joints changes and GCC

Postby arkeon » Thu May 28, 2015 3:41 pm

Hello,
your last changes in custom joint do not compile on GCC 4.9 (NDK)
I already search about this issue on my own code and could not find an equivalent :/

Code: Select all
#define DECLARE_CUSTON_JOINT(className,baseClass)                                                         \
   virtual dCRCTYPE GetSerializeKey() const {return dCRC64(#className);}                                       \
   public:                                                                                       \
   class SerializeMetaData: public baseClass::SerializeMetaData                                             \
   {                                                                                          \
      public:                                                                                    \
      SerializeMetaData(const char* const name)                                                         \
         :baseClass::SerializeMetaData(name)                                                            \
      {                                                                                       \
      }                                                                                       \
      virtual void SerializeJoint (CustomJoint* const joint, NewtonSerializeCallback callback, void* const userData)      \
      {                                                                                       \
         joint->Serialize(callback, userData);                                                         \
      }                                                                                       \
      virtual CustomJoint* DeserializeJoint (NewtonBody* const body0, NewtonBody* const body1,                     \
                                    NewtonDeserializeCallback callback, void* const userData)               \
      {                                                                                       \
         return new className (body0, body1, callback, userData);                                          \
      }                                                                                       \
   };                                                                                          \
   friend class SerializeMetaData;                                                                     \
   static SerializeMetaData m_metaData;

#define IMPLEMENT_CUSTON_JOINT(className)                                                               \
   className::SerializeMetaData className::m_metaData(#className);                                             \

arkeon
 
Posts: 261
Joined: Sat Sep 13, 2014 5:25 pm

Re: Custom joints changes and GCC

Postby arkeon » Thu May 28, 2015 3:58 pm

Also in dNewton.cpp

Code: Select all
dLong timestepMicrosecunds = dLong (...
should be :
dLong timestepMicrosecunds = (dLong) (...

Otherwise GCC complain about it


In dNewtonCollision.h

Code: Select all
CNEWTON_API virtual void OnDrawFace (int vertexCount, const dFloat* const faceVertex, int faceId) = NULL;
should be :
CNEWTON_API virtual void OnDrawFace (int vertexCount, const dFloat* const faceVertex, int faceId) = 0;

NULL is not allowed here by GCC
arkeon
 
Posts: 261
Joined: Sat Sep 13, 2014 5:25 pm

Re: Custom joints changes and GCC

Postby Julio Jerez » Thu May 28, 2015 5:29 pm

the macro, does not compiler?
does it gives any error message?
Julio Jerez
Moderator
Moderator
 
Posts: 11039
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Custom joints changes and GCC

Postby arkeon » Thu May 28, 2015 6:57 pm

No it does not.
the error message is something about the virtual member made outside a class
arkeon
 
Posts: 261
Joined: Sat Sep 13, 2014 5:25 pm

Re: Custom joints changes and GCC

Postby Julio Jerez » Sat May 30, 2015 7:58 pm

I am no sure why you are getting that error, I just build the engine with xcode witch uses Clang and also GCC and it compiled fine.
what platform are you compiling?
Julio Jerez
Moderator
Moderator
 
Posts: 11039
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Custom joints changes and GCC

Postby arkeon » Sun May 31, 2015 4:38 am

I tried with Android NDK with GCC 4.9

it do not support ## string replacement.
I had the same issue on my code I had to remove macros with this.
arkeon
 
Posts: 261
Joined: Sat Sep 13, 2014 5:25 pm

Re: Custom joints changes and GCC

Postby Julio Jerez » Sun May 31, 2015 9:19 am

no support for #string replacement? that sounds like a very extreme compiler limitation.
almost any relatively compile app uses that feature.

is that a known GCC issue?
Julio Jerez
Moderator
Moderator
 
Posts: 11039
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Custom joints changes and GCC

Postby arkeon » Sun May 31, 2015 11:59 am

I don't know it's not easy to found NDK informations :/

As I know it seems it's not fully supported.
arkeon
 
Posts: 261
Joined: Sat Sep 13, 2014 5:25 pm

Re: Custom joints changes and GCC

Postby Julio Jerez » Sun May 31, 2015 12:47 pm

do they have forums where those things is discussed,
Any C++ app is going to be using #string replacement. Maybe I have the syntax is wrong but I do no thong that this is a GCC limitation.
Julio Jerez
Moderator
Moderator
 
Posts: 11039
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Custom joints changes and GCC

Postby arkeon » Sun May 31, 2015 1:01 pm

https://gcc.gnu.org/onlinedocs/cpp/Conc ... catenation

maybe a clue : from http://www.complete-concrete-concise.co ... g-operator

Compiler Differences in handling ##
GCC and Visual C++ handle ## ambiguity differently.

GCC is strict if the resulting concatenation is not a valid preprocessing token – it issues an error during compilation.

Visual C++, on the other hand, reprocesses the concatenation result and will accept constructs that are deemed invalid by GCC.

Both compilers are working correctly, since the standard does not define how an invalid token is to be handled (it just says the behaviour is undefined). Rejecting it is fine as is reprocessing the result and parsing it into valid tokens.

Example:
The following will fail with GCC but succeed with Visual C++

#define macro_start int main ## (void)
After the preprocessor has concatenated main and ( we have the token

main(
which is not a valid token.

GCC rejects it.

On the other hand, Visual C++ reprocesses it producing two tokens: 1) an identifier main and 2) the punctuator / operator (.

Both compilers will correctly process the following

#define macro_increment(x) x+ ## +
because it parses into 2 tokens. The first being the identifier x, the second being the operator ++.
arkeon
 
Posts: 261
Joined: Sat Sep 13, 2014 5:25 pm

Re: Custom joints changes and GCC

Postby Julio Jerez » Sun May 31, 2015 2:33 pm

I just compile the linux build in the UIbuntu Linux which use GCC 4.8.1
and it compiled fine,

I am no sure how to fix that the macro is very straightforward

Code: Select all
virtual dCRCTYPE GetSerializeKey() const {return dCRC64(#className);}                  
and
className::SerializeMetaData className::m_metaData(#className);                     
Julio Jerez
Moderator
Moderator
 
Posts: 11039
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Custom joints changes and GCC

Postby arkeon » Sun May 31, 2015 2:48 pm

you should give it a try with the android ndk.
This is a very weird limitation indeed.
arkeon
 
Posts: 261
Joined: Sat Sep 13, 2014 5:25 pm

Re: Custom joints changes and GCC

Postby arkeon » Mon Jun 01, 2015 5:55 am

#define dgAssert(x) assert(x)

Code: Select all
In file included from D:\dev\scol-technologies\trunk\dependencies\newton-dynamics\coreLibrary_300\source\core\dgStdafx.h:25:0,
                 from D:\dev\scol-technologies\trunk\dependencies\newton-dynamics\coreLibrary_300\source\core\dg.cpp:22:
D:\dev\scol-technologies\trunk\dependencies\newton-dynamics\coreLibrary_300\source\core\dgTypes.h: In function 'void dgRadixSort(T*, T*, dgInt32, dgInt32, dgInt32 (*)(const T*, void*), void*)':
D:\dev\scol-technologies\trunk\dependencies\newton-dynamics\coreLibrary_300\source\core\dgTypes.h:155:32: error: there are no arguments to 'assert' that depend on a template parameter, so a declaratio
n of 'assert' must be available [-fpermissive]
    #define dgAssert(x) assert(x)


Maybe you should try on gcc with or without the -fpermissive flag
arkeon
 
Posts: 261
Joined: Sat Sep 13, 2014 5:25 pm

Re: Custom joints changes and GCC

Postby Julio Jerez » Mon Jun 01, 2015 8:51 am

-permissive flags? is that an compiler option.

I do no understand why are you getting these syntax errors, I can build in Linux without any errors.
Julio Jerez
Moderator
Moderator
 
Posts: 11039
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Custom joints changes and GCC

Postby arkeon » Mon Jun 01, 2015 9:37 am

yes it seems to be a default gcc option on ndk or maybe it's a default option on other compiler
arkeon
 
Posts: 261
Joined: Sat Sep 13, 2014 5:25 pm

Next

Return to Bugs and Fixes

Who is online

Users browsing this forum: No registered users and 4 guests