kicad-developers team mailing list archive
-
kicad-developers team
-
Mailing list archive
-
Message #01914
Re: adding support for MS visual C++ 2005
-
To:
<kicad-devel@xxxxxxxxxxxxxxx>
-
From:
"Carl Rash" <daystar@...>
-
Date:
Tue, 28 Oct 2008 17:30:14 -0400
-
In-reply-to:
<936b14d20810281417m45e0d46boe38a3ac30025846@...>
Im not sure what changes have been made in the code since I ported kicad but here are the gorey details
Building KiCAD with Microsoft Visual C++ 6, 7, 7.1, and 8
nmake -f makefile.vc
Be sure to review all makefile.vc files in the target directories: 3d-viewer, common,
cvpcb, gerbview, eeschema, kicad, and pcbnnew. Verify WXWIN and BOOST_PATH are set to
the correct values.
1) Install Boost libraries and build wxWidgets using the same compiler environment you
intend to use building kicad. Be sure to review all makefile.vc files inthe target
directories: 3d-viewer, common, cvpcb, gerbview, eeschema, kicad, and pcbnnew.
Verify WXWIN and BOOST_PATH are set to the correct values.
2) copy the include file "kicad_msvc.h" to the kicad/kicad-dev/include directory
3) Insert the following code at line 37 of kicad/kicad-dev/include/fctsys.h
#ifdef __MSVC__
#include "kicad_msvc.h"
#endif // def __MSVC__
Source Changes:
**** COMMON ****
1) macros.h line 60 --
need a space between typeof(a) and __temp__
change #define EXCHG( a, b ) { typeof(a)__temp__ = (a); (a) = (b); (b)= __temp__; }
to #define EXCHG( a, b ) { typeof(a) __temp__ = (a); (a) = (b); (b) = __temp__; }
2) eeschema/symbdraw.cpp - Line 584
change ( (LibDrawCircle*) CurrentDrawItem )->m_Rayon = (int) sqrt( (dx *dx) + (dy * dy) );
to ( (LibDrawCircle*) CurrentDrawItem )->m_Rayon = (int) sqrt( (double)(dx * dx) + (double)(dy * dy) );
3) eeschema/symbdraw.cpp - Line 754
change angle = (int) (atan2( dy, dx ) * 1800 / M_PI);
to angle = (int) (atan2( (double)dy, (double)dx ) * 1800.0 / M_PI);
4) eeschema/symbdraw.cpp - Line 768
change DrawItem->m_Rayon = (int) sqrt( (dx * dx) + (dy * dy) );
to DrawItem->m_Rayon = (int) sqrt( (double)(dx * dx) + (double)(dy * dy) );
5) eeschema/symbdraw.cpp - Line 770
change DrawItem->t1 = (int) (atan2( dy, dx ) * 1800 / M_PI);
to DrawItem->t1 = (int) (atan2( (double)dy, (double)dx ) * 1800 /M_PI);
6) eeschema/symbdraw.cpp - Line 775
change DrawItem->t2 = (int) (atan2( dy, dx ) * 1800 / M_PI);
to DrawItem->t2 = (int) (atan2( (double)dy, (double)dx ) * 1800 /M_PI);
7) eeschema/locate.cpp - Line 830
change ii = (int) sqrt( dx * dx + dy * dy );
to ii = (int) sqrt( (double)(dx * dx + dy * dy) );
8) eeschema/locate.cpp - Line 843
change ii = (int) sqrt( dx * dx + dy * dy );
to ii = (int) sqrt( (double)(dx * dx + dy * dy) );
9) eeschema/cleanup.cpp - Line 258
change atan2( RefSegm->m_Start.x - RefSegm->m_End.x, RefSegm->m_Start.y-
RefSegm->m_End.y )
to atan2( (double)(RefSegm->m_Start.x - RefSegm->m_End.x), (double)(RefSegm->m_Start.y -
RefSegm->m_End.y) )
10) eeschema/cleanup.cpp - Line 260
change atan2( TstSegm->m_Start.x - TstSegm->m_End.x, TstSegm->m_Start.y- TstSegm->m_End.y ) )
to atan2( (double)(TstSegm->m_Start.x - TstSegm->m_End.x), (double)(TstSegm->m_Start.y - TstSegm->m_End.y) ) )
11) pcbnew/graphpcb.cpp
change angle = (int) (atan2( dy, dx ) * 1800 / M_PI);
to angle = (int) (atan2( (double)dy, (double)dx ) * 1800 / M_PI);
12) pcbnew/cotation.cpp Line 333
change angle = atan2( deltay, deltax ) + (M_PI / 2);
to angle = atan2( (double)deltay, (double)deltax ) + (M_PI / 2);
13) kicad/treeprj.datas.cpp line 408
change return dynamic_cast<TreePrjItemData*>( m_TreeProject->GetItemData(m_TreeProject->GetSelection() ) );
to return static_cast<TreePrjItemData*>( m_TreeProject->GetItemData( m_TreeProject->GetSelection() ) );
14) kicad/treeprj.datas.cpp line 188
change if( dest == dynamic_cast<TreePrjItemData*>( m_Parent->GetItemData( parent ) ) )
to if( dest == static_cast<TreePrjItemData*>( m_Parent->GetItemData( parent ) ) )
15) kicad/treeprj.datas.cpp line
change dynamic_cast<WinEDA_TreePrj*>( m_Parent )->GetParent()->m_Parent->OnRefresh( dummy );
to static_cast<WinEDA_TreePrj*>( m_Parent )->GetParent()->m_Parent->OnRefresh( dummy );
16) Compiling AMD64 64-bit issues and _MSC_VER >= 1400
pcbnew\class_module.cpp
change strcpy( Line, ctime( &m_LastEdit_Time ) );
to strcpy( Line, ctime( (const time_t *)&m_LastEdit_Time ) );
And the file kicad_msvc.h
// __MSVC__ must be defined
//
// there are several issues
// 1 - the EXCHG macro uses the typeof keyword, this is unsupported in MSVC
// 2 - there is no round function in the msvc math library
// see ReadMe-MSVC.txt to view list of all changes to sources
//
#ifndef __KICAD_MSVC_INC__
#define __KICAD_MSVC_INC__
#ifdef __MSVC__
// the boost libs have a workaround for the typeof problem
#ifdef _MSC_VER
#if ( _MSC_VER <= 1310 ) // 6.5 7.0 and 7.1 use the msvc bug
#include <boost/typeof/msvc/typeof_impl.hpp>
#else // 8.0 or greater
#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 *);
#endif // _MSC_VER <= 1310
#define typeof(expr) BOOST_TYPEOF(expr)
#endif // def _MSC_VER
inline double round(double x)
{
return x >= 0.5 ? ceil(x) : floor(x);
}
// we get hundreds of these warnings: truncation from 'double' to 'float'
// when compiling trigo.h
#pragma warning( disable :4305 )
#endif // def __MSVC__
#endif // ndef __KICAD_MSVC_INC__
----- Original Message -----
From: Manveru
To: kicad-devel@xxxxxxxxxxxxxxx
Sent: Tuesday, October 28, 2008 5:17 PM
Subject: Re: [kicad-devel] adding support for MS visual C++ 2005
2008/10/28 Carl Rash <daystar@...>:
> 
>
> There are many reasons why one may want to use a Microsoft compiler on a
> windows operating system. The primary reason is the quality of the binary
> code and the superior debugging tools that are available. Jean Pierre you
> may remember with I found a stack corruption bug caused by an array
> allocation error as a local variable using the Microsoft debug code. You
> fixed the problem when I informed you. This is onlyone of several bugs
> identified in that release by the MS debugger/
> I have the complete make files for building version 2007-11-29-RC2 on any
> version of MSVC post 2004 .net if any one is interested. I stopped porting
> to MS when Kicads direction seemed to be taken over by those who literally
> despise the word WIndows or Microsoft.
> I would be glad to share what I have, just let me know.
>
> Carl Rash
CMAKE is enough as a build system for Microsoft compiler. Only
problems are code incompabilities with libraries available for M$.
You have right that debbugger is very good and helpful.
M.
------=_NextPart_000_0076_01C93922.D7826C90 Content-Type: text/html;
charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=utf-8">
<META content="MSHTML 6.00.6001.18148" name=GENERATOR></HEAD>
<BODY style="BACKGROUND-COLOR: #ffffff" bgColor=#ffffff>
<DIV><FONT face=Arial size=2>Im not sure what changes have been made inthe code
since I ported kicad but here are the gorey details</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Building KiCAD with Microsoft Visual C++ 6, 7, 7.1,
and 8</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>nmake -f makefile.vc</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Be sure to review all makefile.vc files inthe
target directories: 3d-viewer, common,<BR>cvpcb, gerbview, eeschema, kicad,and
pcbnnew. Verify WXWIN and BOOST_PATH are set to<BR>the correct
values.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV><FONT face=Arial size=2>
<DIV><BR>1) Install Boost libraries and build wxWidgets using the same compiler
environment you<BR> intend to use building kicad. Be sure to review
all makefile.vc files in the target <BR> directories: 3d-viewer,
common, cvpcb, gerbview, eeschema, kicad, and pcbnnew. <BR> Verify
WXWIN and BOOST_PATH are set to the correct values.</DIV>
<DIV> </DIV>
<DIV>2) copy the include file "kicad_msvc.h" to the kicad/kicad-dev/include
directory</DIV>
<DIV> </DIV>
<DIV>3) Insert the following code at line 37 of kicad/kicad-dev/include/fctsys.h
</DIV>
<DIV> </DIV>
<DIV>#ifdef __MSVC__<BR>#include "kicad_msvc.h"</DIV>
<DIV> </DIV>
<DIV>#endif // def __MSVC__</DIV>
<DIV> </DIV>
<DIV>Source Changes:</DIV>
<DIV> </DIV>
<DIV>**** COMMON ****<BR>1) macros.h line 60 --<BR>need a space between
typeof(a) and __temp__<BR> change #define EXCHG( a, b ) { typeof(a)__temp__
= (a); (a) = (b); (b) = __temp__; }<BR> to #define
EXCHG( a, b ) { typeof(a) __temp__ = (a); (a) = (b); (b) = __temp__; }</DIV>
<DIV> </DIV>
<DIV>2) eeschema/symbdraw.cpp - Line 584<BR> change ( (LibDrawCircle*)
CurrentDrawItem )->m_Rayon = (int) sqrt( (dx * dx) + (dy * dy)
);<BR> to ( (LibDrawCircle*) CurrentDrawItem
)->m_Rayon = (int) sqrt( (double)(dx * dx) + (double)(dy * dy) );</DIV>
<DIV> </DIV>
<DIV>3) eeschema/symbdraw.cpp - Line 754<BR> change
angle = (int) (atan2( dy, dx ) * 1800 /
M_PI);<BR> to angle = (int)
(atan2( (double)dy, (double)dx ) * 1800.0 / M_PI);</DIV>
<DIV> </DIV>
<DIV>4) eeschema/symbdraw.cpp - Line 768<BR> change
DrawItem->m_Rayon = (int) sqrt( (dx * dx) + (dy * dy)
);<BR> to DrawItem->m_Rayon =
(int) sqrt( (double)(dx * dx) + (double)(dy * dy) );</DIV>
<DIV> </DIV>
<DIV>5) eeschema/symbdraw.cpp - Line 770<BR> change
DrawItem->t1 = (int) (atan2( dy, dx ) * 1800 /
M_PI);<BR> to DrawItem->t1 =
(int) (atan2( (double)dy, (double)dx ) * 1800 / M_PI);</DIV>
<DIV> </DIV>
<DIV>6) eeschema/symbdraw.cpp - Line 775<BR> change
DrawItem->t2 = (int) (atan2( dy, dx ) * 1800 /
M_PI);<BR> to DrawItem->t2 =
(int) (atan2( (double)dy, (double)dx ) * 1800 / M_PI);</DIV>
<DIV> </DIV>
<DIV>7) eeschema/locate.cpp - Line 830<BR> change ii=
(int) sqrt( dx * dx + dy * dy
);<BR> to ii = (int) sqrt(
(double)(dx * dx + dy * dy) );</DIV>
<DIV> </DIV>
<DIV>8) eeschema/locate.cpp - Line 843<BR> change ii=
(int) sqrt( dx * dx + dy * dy
);<BR> to ii = (int) sqrt(
(double)(dx * dx + dy * dy) );</DIV>
<DIV> </DIV>
<DIV>9) eeschema/cleanup.cpp - Line 258<BR> change atan2(
RefSegm->m_Start.x - RefSegm->m_End.x, RefSegm->m_Start.y
-<BR>
RefSegm->m_End.y )<BR> to
atan2( (double)(RefSegm->m_Start.x - RefSegm->m_End.x),
(double)(RefSegm->m_Start.y
-<BR>
RefSegm->m_End.y) )<BR>10) eeschema/cleanup.cpp - Line
260<BR> change atan2( TstSegm->m_Start.x -
TstSegm->m_End.x, TstSegm->m_Start.y - TstSegm->m_End.y )
)<BR> to atan2(
(double)(TstSegm->m_Start.x - TstSegm->m_End.x),
(double)(TstSegm->m_Start.y - TstSegm->m_End.y) ) )</DIV>
<DIV> </DIV>
<DIV>11) pcbnew/graphpcb.cpp<BR> change angle = (int)
(atan2( dy, dx ) * 1800 /
M_PI);<BR> to angle = (int)
(atan2( (double)dy, (double)dx ) * 1800 / M_PI);</DIV>
<DIV> </DIV>
<DIV>12) pcbnew/cotation.cpp Line 333<BR> change angle =
atan2( deltay, deltax ) + (M_PI /
2);<BR> to angle = atan2(
(double)deltay, (double)deltax ) + (M_PI / 2);</DIV>
<DIV> </DIV>
<DIV>13) kicad/treeprj.datas.cpp line 408<BR> change return
dynamic_cast<TreePrjItemData*>( m_TreeProject->GetItemData(
m_TreeProject->GetSelection() ) );<BR> to
return static_cast<TreePrjItemData*>( m_TreeProject->GetItemData(
m_TreeProject->GetSelection() ) );<BR>14) kicad/treeprj.datas.cpp line
188<BR> change if( dest == dynamic_cast<TreePrjItemData*>(
m_Parent->GetItemData( parent ) ) )<BR> to if(
dest == static_cast<TreePrjItemData*>( m_Parent->GetItemData( parent )
) )<BR>15) kicad/treeprj.datas.cpp line <BR> change
dynamic_cast<WinEDA_TreePrj*>( m_Parent
)->GetParent()->m_Parent->OnRefresh( dummy );<BR>
to static_cast<WinEDA_TreePrj*>( m_Parent
)->GetParent()->m_Parent->OnRefresh( dummy );</DIV>
<DIV> </DIV>
<DIV><BR>16) Compiling AMD64 64-bit issues and _MSC_VER >=
1400<BR>pcbnew\class_module.cpp <BR> change strcpy( Line, ctime(
&m_LastEdit_Time ) );<BR> to strcpy( Line,
ctime( (const time_t *)&m_LastEdit_Time ) );<BR> <BR>And the file
kicad_msvc.h</DIV>
<DIV> </DIV>
<DIV>// __MSVC__ must be defined </DIV>
<DIV> </DIV>
<DIV>//<BR>// there are several issues<BR>// 1 - the EXCHG macro uses the typeof
keyword, this is unsupported in MSVC<BR>// 2 - there is no round function in the
msvc math library<BR>// see ReadMe-MSVC.txt to view list of all changes to
sources<BR>//<BR>#ifndef __KICAD_MSVC_INC__<BR>#define __KICAD_MSVC_INC__</DIV>
<DIV> </DIV>
<DIV>#ifdef __MSVC__<BR>// the boost libs have a workaround for the typeof
problem<BR>#ifdef _MSC_VER<BR> #if ( _MSC_VER <= 1310 ) // 6.5 7.0 and
7.1 use the msvc bug <BR> #include
<boost/typeof/msvc/typeof_impl.hpp><BR> #else // 8.0 or
greater<BR> #include <boost/typeof/typeof.hpp><BR> // we have
to register the types used with the typeof keyword with boost<BR>
BOOST_TYPEOF_REGISTER_TYPE(wxPoint);<BR>
BOOST_TYPEOF_REGISTER_TYPE(wxSize);<BR>
BOOST_TYPEOF_REGISTER_TYPE(wxString);<BR> class
DrawSheetLabelStruct;<BR> BOOST_TYPEOF_REGISTER_TYPE(DrawSheetLabelStruct
*);<BR> class EDA_BaseStruct;<BR>
BOOST_TYPEOF_REGISTER_TYPE(EDA_BaseStruct *);<BR> class D_PAD;<BR>
BOOST_TYPEOF_REGISTER_TYPE(D_PAD *);<BR> BOOST_TYPEOF_REGISTER_TYPE(const
D_PAD *);<BR> class BOARD_ITEM;<BR>
BOOST_TYPEOF_REGISTER_TYPE(BOARD_ITEM *);<BR> #endif // _MSC_VER <=
1310<BR> #define typeof(expr) BOOST_TYPEOF(expr)<BR>#endif // def
_MSC_VER</DIV>
<DIV> </DIV>
<DIV>inline double round(double x)<BR>{<BR> return x >= 0.5 ? ceil(x) :
floor(x);<BR>}</DIV>
<DIV> </DIV>
<DIV>// we get hundreds of these warnings: truncation from 'double' to
'float'<BR>// when compiling trigo.h</DIV>
<DIV> </DIV>
<DIV>#pragma warning( disable :4305 )</DIV>
<DIV> </DIV>
<DIV><BR>#endif // def __MSVC__</DIV>
<DIV> </DIV>
<DIV>#endif // ndef __KICAD_MSVC_INC__<BR></FONT></DIV>
<BLOCKQUOTE
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV style="FONT: 10pt arial">----- Original Message ----- </DIV>
<DIV
style="BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: black"><B>From:</B>
<A title=manveru@... href="mailto:manveru@...">Manveru</A>
</DIV>
<DIV style="FONT: 10pt arial"><B>To:</B> <A title=kicad-devel@xxxxxxxxxxxxxxx
href="mailto:kicad-devel@xxxxxxxxxxxxxxx">kicad-devel@xxxxxxxxxxxxxxx</A>
</DIV>
<DIV style="FONT: 10pt arial"><B>Sent:</B> Tuesday, October 28, 2008 5:17
PM</DIV>
<DIV style="FONT: 10pt arial"><B>Subject:</B> Re: [kicad-devel] adding support
for MS visual C++ 2005</DIV>
<DIV><BR></DIV>
<DIV id=ygrp-text>
<P>2008/10/28 Carl Rash <<A
href="mailto:daystar@...">daystar@triad.<WBR>rr.com</A>>:<BR>>
<BR>><BR>> There are many reasons why one may want to use a Microsoft
compiler on a<BR>> windows operating system. The primary reason is the
quality of the binary<BR>> code and the superior debugging tools that are
available. Jean Pierre you<BR>> may remember with I found a stack
corruption bug caused by an array<BR>> allocation error as a local variable
using the Microsoft debug code. You<BR>> fixed the problem when I informed
you. This is onlyone of several bugs<BR>> identified in that release by the
MS debugger/<BR>> I have the complete make files for building version
2007-11-29-RC2 on any<BR>> version of MSVC post 2004 .net if any one is
interested. I stopped porting<BR>> to MS when Kicads direction seemed to be
taken over by those who literally<BR>> despise the word WIndows or
Microsoft.<BR>> I would be glad to share what I have, just let me
know.<BR>><BR>> Carl Rash<BR><BR>CMAKE is enough as a build system for
Microsoft compiler. Only<BR>problems are code incompabilities with libraries
available for M$.<BR><BR>You have right that debbugger is very good and
helpful.<BR><BR>M.<BR></P></DIV><!--End group email --></BLOCKQUOTE></BODY></HTML>
------=_NextPart_000_0076_01C93922.D7826C90--
References