error: invalid lvalue in asm input for constraint 'm'

Hello guys,

I got these 2 errors while setting up my environment in Mac OS X following the instructions listed in: https://www.panda3d.org/manual/index.php/How_to_compile_a_CXX_Panda3D_program_on_Mac_OS_X

$g++ -c hello.cxx -o hello.o -fPIC -O2 -arch i386 -I /usr/include/python2.5/ -I /Developer/Panda3D/include/
In file included from hello.cxx:1:
In file included from /Developer/Panda3D/include/pandaFramework.h:20:
In file included from /Developer/Panda3D/include/windowFramework.h:19:
In file included from /Developer/Panda3D/include/nodePath.h:23:
In file included from /Developer/Panda3D/include/pandaNode.h:20:
In file included from /Developer/Panda3D/include/cycleData.h:19:
In file included from /Developer/Panda3D/include/typeHandle.h:19:
In file included from /Developer/Panda3D/include/typeRegistry.h:20:
In file included from /Developer/Panda3D/include/memoryBase.h:19:
In file included from /Developer/Panda3D/include/memoryHook.h:20:
In file included from /Developer/Panda3D/include/atomicAdjust.h:31:
In file included from /Developer/Panda3D/include/atomicAdjustI386Impl.h:56:
/Developer/Panda3D/include/atomicAdjustI386Impl.I:35:30: error: invalid lvalue
      in asm input for constraint 'm'
                       :"m" (&var));
                             ^~~~
/Developer/Panda3D/include/atomicAdjustI386Impl.I:62:30: error: invalid lvalue
      in asm input for constraint 'm'
                       :"m" (&var) : "memory");
                             ^~~~
2 errors generated.

I am running the latest stable Panda (1.8.1) in Mac OS X 10.8.4. (Python “Hello World” works perfectly but I need to work with C++).

This is the body of one of the functions that causes these errors (atomicAdjustI386Impl.I)


////////////////////////////////////////////////////////////////////
//     Function: AtomicAdjustI386Impl::inc
//       Access: Public, Static
//  Description: Atomically increments the indicated variable.
////////////////////////////////////////////////////////////////////
INLINE void AtomicAdjustI386Impl::
inc(TVOLATILE AtomicAdjustI386Impl::Integer &var) {
  assert((((size_t)&var) & (sizeof(Integer) - 1)) == 0);
#ifdef _M_IX86
  // Windows case
  TVOLATILE Integer *var_ptr = &var;
  __asm {
    mov edx, var_ptr;
    lock inc dword ptr [edx];
  }
#elif !defined(__EDG__)
  // GCC case
  __asm__ __volatile__("lock; incl %0"
                       :"=m" (var)
                       :"m" (&var));
#endif  // __EDG__
}

Thanks in advance for your help! :smiley:

Problem solved: I used Panda3D 1.7.2 instead of the latest 1.8.1.

Sadly… I’m afraid that’s not what fixed your problem.

I’m using 1.8.1, and I have that same compilation problem.
Note that I only have it when I compile with the -arch i386 flag… I don’t have any issues compiling my program in 64bit (though I haven’t tried compiling Panda3D in 64bit for that platform).

Hi!

I know this is a bit old, but did you manage to solve the problem?

Thanks

After much fight, I managed to do it.

Just download and install the package at http://rdb.name/Panda3D-1.9.0.dmg. Found it through this post [url]OSX Mavericks Compile Issue].