Data type conflicts

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 25/09/2010 at 14:06, xxxxxxxx wrote:

User Information:
Cinema 4D Version:   R12 
Platform:   Windows  ;   
Language(s) :     C++  ;

---------
I need to include <windows.h> in my Melange source code files, however, "c4d_system.h" is not very friendly
with it.  I'm getting hundreds of errors:
c:\melange\commandline\source\alien_def.h(29) : error C2872: 'LONG' : ambiguous symbol
        could be 'C:\Program Files\Microsoft SDKs\Windows\v6.0A\\include\winnt.h(278) : long LONG'
        or       'c:\melange\_melange\includes\c4d_system.h(85) : _melange_::LONG'
.\source est.cpp(2252) : error C2872: 'LONG' : ambiguous symbol
        could be 'C:\Program Files\Microsoft SDKs\Windows\v6.0A\\include\winnt.h(278) : long LONG'
        or       'c:\melange\_melange\includes\c4d_system.h(85) : _melange_::LONG'
.\source est.cpp(2253) : error C2872: 'CHAR' : ambiguous symbol
        could be 'C:\Program Files\Microsoft SDKs\Windows\v6.0A\\include\winnt.h(276) : char CHAR'
        or       'c:\melange\_melange\includes\c4d_system.h(95) : _melange_::CHAR'
.\source est.cpp(2264) : error C2872: 'UCHAR' : ambiguous symbol
.\source est.cpp(2264) : fatal error C1003: error count exceeds 100; stopping compilation
How can I resolve these data type conflicts?  I absolutely need to use <windows.h>.
I'm using the commandline example from the Melange library.
My header looks like:
#include <windows.h>
#include "C4DImportExport.h"

And if I comment out this line in alien_def.h
//using namespace _melange_;
I still get hundreds of errors.

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 25/09/2010 at 18:13, xxxxxxxx wrote:

It appears as though the Windows API is using the same data type as C4D...    LONG..    Is there a a way to use "long" (the C++ type) instead of LONG (the c4d type)?  probably not as many of the functions probably rely on LONG.    hmmmm....  Why do you need the Windows.h ?

~Shawn

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 25/09/2010 at 18:20, xxxxxxxx wrote:

The problem isn't me using LONG.  It's the Melange library using it.
There's also conflicts with INT, UINT, CHAR, and UCHAR, all over the place.
 
I'm using functions from <windows.h>, so it's absolutely necessary that it's included.

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 25/09/2010 at 18:24, xxxxxxxx wrote:

EDIT:  Sorry read your post after I posted.

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 29/09/2010 at 11:28, xxxxxxxx wrote:

to avoid those type conflicts you could include windows.h in your test.cpp file only.

if you need it in your header file e.g. alien_def.h please change the line

using namespace _melange_;
to
namespace _melange_
{
...
}
-> this at the end of the file

in C4DImportExport.cpp add the same lines after #include "C4DImportExport.h" (the "}" at the end of the file again)

then you have to move the following definitions outside the namespace definition:
GetWriterInfo()
AllocAlienTagData()
AllocAlienObjectData()
AllocAlienRootMaterial()
AllocAlienRootObject()
AllocAlienRootLayer()
AllocAlienRootRenderData()
AllocC4DRootViewPanel()
AllocAlienLayer()

move these to the last line after the _melange_ namespace and add the namespace name before the types like this:
__melange_::RootMaterial *AllocAlienRootMaterial()                { return gNew _melange_::AlienRootMaterial; }
_melange_::RootObject *AllocAlienRootObject()                         { return gNew _melange_::AlienRootObject; }
_melange_::RootLayer *AllocAlienRootLayer()                              { return gNew _melange_::AlienRootLayer; }
_melange_::RootRenderData *AllocAlienRootRenderData()     { return gNew _melange_::AlienRootRenderData; }
_melange_::RootViewPanel *AllocC4DRootViewPanel()               { return gNew _melange_::RootViewPanel; }
_melange_::LayerObject *AllocAlienLayer()                                   { return gNew _melange_::AlienLayer; }

_melange_::NodeData *AllocAlienObjectData(_melange_::LONG id, _melange_::Bool &known;)
{
     _melange_::NodeData *m_data = NULL;
     known = TRUE;
     switch (id)
     {
          //supported element types
     case Ocamera:                    m_data = gNew _melange_::AlienCameraObjectData; break;
   ...

_melange_::NodeData *AllocAlienTagData(_melange_::LONG id, _melange_::Bool &known;)
{
     _melange_::NodeData *m_data = NULL;
   ...

void GetWriterInfo(_melange_::LONG &id;, _melange_::String &appname; )
{
   ...
_
hope this helps!

cheers
jens

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 29/09/2010 at 12:16, xxxxxxxx wrote:

I found a more simple solution.  Melange must use data types provided by Windows.
I had to replace _melange_::LONG with LONG, and I commented out all these typedefs:

  
//typedef long   LONG;  
//typedef unsigned long  ULONG;  
//typedef int   INT;  
//typedef unsigned int  UINT;  
//typedef char   CHAR;  
//typedef unsigned char  UCHAR;  

Or, if you want to leave them in, you can do this:

  
// check for "windows.h" header  
#ifndef _WINDOWS_  
typedef long   LONG;  
typedef unsigned long  ULONG;  
typedef int   INT;  
typedef unsigned int  UINT;  
typedef char   CHAR;  
typedef unsigned char  UCHAR;  
#endif // _WINDOWS_