[-fpermissive] ???

Anything and everything that's related to OGRE or the wider graphics field that doesn't fit into the other forums.
Post Reply
levan
Halfling
Posts: 41
Joined: Sun Oct 27, 2013 11:57 pm
x 1

[-fpermissive] ???

Post by levan »

Hello

I am trying just to create a vector object in my executable .cpp like this :

Ogre::Vector3 transVector = Ogre::Vector3::Vector3(1,1,1);


and getting following errors during the compilation.

error: cannot call constructor 'Ogre::Vector3::Vector3' directly [-fpermissive]

error: for a function-style cast, remove the redundant '::Vector3' [-fpermissive]

can you please tell me what is wrong there.


best

levan
scrawl
OGRE Expert User
OGRE Expert User
Posts: 1119
Joined: Sat Jan 01, 2011 7:57 pm
x 216

Re: [-fpermissive] ???

Post by scrawl »

Ogre::Vector3 transVector = Ogre::Vector3(1,1,1);
Or even simpler:
Ogre::Vector3 transVector (1,1,1);
User avatar
tod
Troll
Posts: 1394
Joined: Wed Aug 02, 2006 9:41 am
Location: Bucharest
x 94
Contact:

Re: [-fpermissive] ???

Post by tod »

Second option is better. The first one creates a temporary vector3 and then calls a copy constructor, which is unnecessary.
scrawl
OGRE Expert User
OGRE Expert User
Posts: 1119
Joined: Sat Jan 01, 2011 7:57 pm
x 216

Re: [-fpermissive] ???

Post by scrawl »

The compiler will usually optimize that away. See Copy elision.
So use whatever you find easier to read.
levan
Halfling
Posts: 41
Joined: Sun Oct 27, 2013 11:57 pm
x 1

Re: [-fpermissive] ???

Post by levan »

many thanks
Post Reply