← Back to team overview

kicad-developers team mailing list archive

Build error on MSVC

 

Hi,

I'm getting a compile error on MSVC:

eeschema\lib_pin.cpp(588): error C2228: left of '.utf8_str' must have
class/struct/union

I can't prove easily whether this code is legal or illegal according to
the C++ specification, which is probably a good reason to change it.

   Simon
From ce1b884ac0d357963dd496662444669c355f1c5e Mon Sep 17 00:00:00 2001
From: Simon Richter <Simon.Richter@xxxxxxxxxx>
Date: Tue, 19 Sep 2017 21:00:06 +0200
Subject: [PATCH] Avoid converting fixed string to UTF-8

This fixes a build error on MSVC. The code may actually be legal, but a
proof of that would require a lengthy dissertation on argument promotion
rules for the ternary operator, and the simplest rule of promoting both
cases to a wxString rvalue is not likely to be what is intended here.

Fortunately, this expression can be simplified.
---
 eeschema/lib_pin.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/eeschema/lib_pin.cpp b/eeschema/lib_pin.cpp
index f3213cc7a..786181f82 100644
--- a/eeschema/lib_pin.cpp
+++ b/eeschema/lib_pin.cpp
@@ -585,7 +585,7 @@ bool LIB_PIN::Save( OUTPUTFORMATTER& aFormatter )
     }
 
     if( aFormatter.Print( 0, " %s %d %d %d %c %d %d %d %d %c",
-                          TO_UTF8( m_number.IsEmpty() ? wxT( "~" ) : m_number ),
+                          m_number.IsEmpty() ? "~" : TO_UTF8( m_number ),
                           m_position.x, m_position.y,
                           (int) m_length, (int) m_orientation, m_numTextSize, m_nameTextSize,
                           m_Unit, m_Convert, Etype ) < 0 )
-- 
2.11.0

Attachment: signature.asc
Description: OpenPGP digital signature


Follow ups