kicad-developers team mailing list archive
-
kicad-developers team
-
Mailing list archive
-
Message #26398
Re: export_vrml.cpp warnings
Thanks, that's probably a bad C habit on my part. :) The most ancient of
C++ specs
were more lenient with magic int-enum casts. All the more reason to use
"enum class"
from now on; after all it was explicitly to address problems like this.
Fix attached; the patch also removes the few instances of wxT() in that
file.
- Cirilo
On Fri, Sep 23, 2016 at 5:01 AM, Simon Wells <swel024@xxxxxxxxx> wrote:
> i am getting the following warning
>
> /Users/simon/kicad-app/kicad/pcbnew/exporters/export_vrml.cpp:1624:18:
> warning:
> comparison of constant -1 with expression of type 'VRML_COLOR_INDEX'
> is
> always false [-Wtautological-constant-out-of-range-compare]
>
> if( colorIdx == -1 )
> ~~~~~~~~ ^ ~~
>
> the enum is specified as
>
> enum VRML_COLOR_INDEX
> {
> VRML_COLOR_PCB = 0,
> VRML_COLOR_TRACK,
> VRML_COLOR_SILK,
> VRML_COLOR_TIN,
> VRML_COLOR_LAST
> };
>
> as the expression is if (colorIdx == -1 ) colorIdx = VRML_COLOR_PCB
> would it not be worth adding a value for -1 into the enum (not sure
> whether it should be VRML_COLOR_AUTO or VRML_COLOR_UNSPECIFIED)
>
> thanks
>
> Simon
>
> _______________________________________________
> Mailing list: https://launchpad.net/~kicad-developers
> Post to : kicad-developers@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~kicad-developers
> More help : https://help.launchpad.net/ListHelp
>
From dee93d77eab2072a4b11551557884fe39abf5008 Mon Sep 17 00:00:00 2001
From: Cirilo Bernardo <cirilo.bernardo@xxxxxxxxx>
Date: Fri, 23 Sep 2016 08:20:17 +1000
Subject: [PATCH] Fix bad enum compare (VRML_COLOR_INDEX) and remove wxT()
instances
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="------------2.9.3"
This is a multi-part message in MIME format.
--------------2.9.3
Content-Type: text/plain; charset=UTF-8; format=fixed
Content-Transfer-Encoding: 8bit
---
pcbnew/exporters/export_vrml.cpp | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)
--------------2.9.3
Content-Type: text/x-patch; name="0001-Fix-bad-enum-compare-VRML_COLOR_INDEX-and-remove-wxT.patch"
Content-Transfer-Encoding: 8bit
Content-Disposition: attachment; filename="0001-Fix-bad-enum-compare-VRML_COLOR_INDEX-and-remove-wxT.patch"
diff --git a/pcbnew/exporters/export_vrml.cpp b/pcbnew/exporters/export_vrml.cpp
index f6c617a..7fc0a76 100644
--- a/pcbnew/exporters/export_vrml.cpp
+++ b/pcbnew/exporters/export_vrml.cpp
@@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2009-2013 Lorenzo Mercantonio
- * Copyright (C) 2014 Cirilo Bernardo
+ * Copyright (C) 2014-2016 Cirilo Bernardo
* Copyright (C) 2013 Jean-Pierre Charras jp.charras at wanadoo.fr
* Copyright (C) 2004-2016 KiCad Developers, see AUTHORS.txt for contributors.
*
@@ -131,6 +131,7 @@ struct VRML_COLOR
enum VRML_COLOR_INDEX
{
+ VRML_COLOR_NONE = -1,
VRML_COLOR_PCB = 0,
VRML_COLOR_TRACK,
VRML_COLOR_SILK,
@@ -831,9 +832,8 @@ static void export_vrml_board( MODEL_VRML& aModel, BOARD* pcb )
if( !pcb->GetBoardPolygonOutlines( bufferPcbOutlines, allLayerHoles, &msg ) )
{
- msg << wxT( "\n\n" ) <<
- _( "Unable to calculate the board outlines;\n"
- "fall back to using the board boundary box." );
+ msg << "\n\n" <<
+ _( "Unable to calculate the board outlines; fall back to using the board boundary box." );
wxMessageBox( msg );
}
@@ -863,8 +863,8 @@ static void export_vrml_board( MODEL_VRML& aModel, BOARD* pcb )
if( seg < 0 )
{
- msg << wxT( "\n\n" ) <<
- _( "VRML Export Failed:\nCould not add holes to contours." );
+ msg << "\n\n" <<
+ _( "VRML Export Failed: Could not add holes to contours." );
wxMessageBox( msg );
return;
@@ -1413,7 +1413,7 @@ static void export_vrml_module( MODEL_VRML& aModel, BOARD* aPcb, MODULE* aModule
if( srcModTime != destModTime )
{
- wxLogDebug( wxT( "Copying 3D model %s to %s." ),
+ wxLogDebug( "Copying 3D model %s to %s.",
GetChars( srcFile.GetFullPath() ),
GetChars( dstFile.GetFullPath() ) );
@@ -1459,14 +1459,14 @@ static void export_vrml_module( MODEL_VRML& aModel, BOARD* aPcb, MODULE* aModule
if( USE_RELPATH )
{
wxFileName tmp = dstFile;
- tmp.SetExt( wxT( "" ) );
- tmp.SetName( wxT( "" ) );
+ tmp.SetExt( "" );
+ tmp.SetName( "" );
tmp.RemoveLastDir();
dstFile.MakeRelativeTo( tmp.GetPath() );
}
wxString fn = dstFile.GetFullPath();
- fn.Replace( wxT( "\\" ), wxT( "/" ) );
+ fn.Replace( "\\", "/" );
output_file << TO_UTF8( fn ) << "\"\n } ]\n";
output_file << " }\n";
}
@@ -1568,7 +1568,7 @@ bool PCB_EDIT_FRAME::ExportVRML_File( const wxString& aFullFileName, double aMMt
// Begin with the usual VRML boilerplate
wxString fn = aFullFileName;
- fn.Replace( wxT( "\\" ), wxT( "/" ) );
+ fn.Replace( "\\" , "/" );
output_file << "#VRML V2.0 utf8\n";
output_file << "WorldInfo {\n";
output_file << " title \"" << TO_UTF8( fn ) << " - Generated by Pcbnew\"\n";
--------------2.9.3--
Follow ups
References