better code compatibility with others compilers (MSVC)

This commit is contained in:
charras 2008-10-30 20:12:29 +00:00
parent 645f7384c9
commit 07767585c3
11 changed files with 94 additions and 38 deletions

View File

@ -1,6 +1,7 @@
add_definitions(-DPCBNEW)
include_directories(../pcbnew
include_directories(${Boost_INCLUDE_DIR}
../pcbnew
../polygon)
set(3D-VIEWER_SRCS

View File

@ -10,6 +10,10 @@ email address.
================================================================================
++All
Use double instead float when possible, ande code cleaning.
Some changes for a better code compatibility with others compliers (MSVC)
(__MSVC__ must be defined when using MSVC)
(double round(double) and typeof unkown in MSVC)
Note: I cannot test kicad under MSVC.
2008-Oct-19 UPDATE Dick Hollenbeck <dick@softplc.com>

View File

@ -1,3 +1,6 @@
include_directories(${CMAKE_CURRENT_SOURCE_DIR}
${Boost_INCLUDE_DIR}
)
set(COMMON_SRCS
about_kicad.cpp
base_screen.cpp

View File

@ -7,14 +7,11 @@
/* Fichier base_struct.cpp */
#include "fctsys.h"
#include "gr_basic.h"
#include "trigo.h"
#include "macros.h"
#include "common.h"
#include "wxstruct.h"
#include "base_struct.h"
#include "grfonte.h"
#include "macros.h"
enum textbox {

View File

@ -555,3 +555,15 @@ wxString& operator <<( wxString& aString, const wxPoint& aPos )
return aString;
}
#ifdef __MSVC__ // compilers that does not have the round function (posix)
/* return the nearest rounded ( equivalent to the nearest integer value)
* from aNumber
*/
double round( double aNumber )
{
return floor( aNumber + 0.5 );
}
#endif

View File

@ -1,6 +1,7 @@
add_definitions(-DCVPCB)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}
${Boost_INCLUDE_DIR}
../3d-viewer
../pcbnew
../polygon)

View File

@ -1,7 +1,7 @@
add_definitions(-DEESCHEMA)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}
# ${Boost_INCLUDE_DIR}
${Boost_INCLUDE_DIR}
)
set(EESCHEMA_SRCS

View File

@ -1,6 +1,7 @@
add_definitions(-DGERBVIEW -DPCBNEW)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}
${Boost_INCLUDE_DIR}
../3d-viewer
../cvpcb
../pcbnew

View File

@ -405,12 +405,20 @@ wxString& operator <<( wxString& aString, const wxPoint& aPoint );
bool ProcessExecute( const wxString& aCommandLine, int aFlags = wxEXEC_ASYNC );
/**
* Function ReturnPcbLayerName
* @return a wxString containing the name of the layer number "layer_number".
* @param layer_number the layer number of the layer
* @param is_filename if TRUE, the name can be used for a file name (not internatinalized, no space)
*/
wxString ReturnPcbLayerName( int layer_number, bool is_filename = FALSE );
/* Return the name of the layer number "layer_number".
* if "is_filename" == TRUE, the name can be used for a file name
* (not internatinalized, no space)*/
#ifdef __MSVC__ // compilers that does not have the round function (posix)
/* return the near rounded (like the equivalent integer value) from aNumber
*/
double round( double aNumber );
#endif
/**************/
/* DRAWTXT.CPP */

View File

@ -50,10 +50,35 @@
Angle -= 1800; }
/****************************************/
/* inline functions to exchange 2 items */
/****************************************/
/*****************************/
/* macro to exchange 2 items */
/*****************************/
/* this macro uses the typeof keyword
* for compilers that do not know typeof (MSVC )
* the boost libs have a workaround for the typeof problem
*/
#ifdef __MSVC__ // MSCV does not know typeof. Others def can be added here
#include "boost/typeof/typeof.hpp"
// we have to register the types used with the typeof keyword with boost
BOOST_TYPEOF_REGISTER_TYPE( wxPoint );
BOOST_TYPEOF_REGISTER_TYPE( wxSize );
BOOST_TYPEOF_REGISTER_TYPE( wxString );
class DrawSheetLabelStruct;
BOOST_TYPEOF_REGISTER_TYPE( DrawSheetLabelStruct* );
class EDA_BaseStruct;
BOOST_TYPEOF_REGISTER_TYPE( EDA_BaseStruct* );
class D_PAD;
BOOST_TYPEOF_REGISTER_TYPE( D_PAD* );
BOOST_TYPEOF_REGISTER_TYPE( const D_PAD* );
class BOARD_ITEM;
BOOST_TYPEOF_REGISTER_TYPE( BOARD_ ITEM* );
#define typeof (expr)BOOST_TYPEOF( expr )
#endif // #ifdef __MSVC__
// here is the macro:
#define EXCHG( a, b ) { typeof(a)__temp__ = (a); (a) = (b); (b) = __temp__; }

View File

@ -1,5 +1,9 @@
add_definitions(-DKICAD)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}
${Boost_INCLUDE_DIR}
)
set(KICAD_SRCS
buildmnu.cpp
commandframe.cpp