nimbuscontrols / EIPScanner

Free implementation of EtherNet/IP in C++
https://eipscanner.readthedocs.io/en/latest/
MIT License
238 stars 98 forks source link

Resolve issue in CipBaseString, properly assign vector size #73

Closed Broekman closed 2 years ago

Broekman commented 2 years ago

See https://github.com/nimbuscontrols/EIPScanner/pull/70#issuecomment-1072870360 for details.

JohannesKauffmann commented 2 years ago

Thanks a lot for spotting this error. There should probaly be a unit test which tests the conversion from std::string to CipString and back.

The only problem I see with your PR is that it breaks compilation on MSVC for me. The problem is that in order to use std::back_inserter, the <iterator> header needs to be included. GCC probably includes it via transitive includes, but that is not the case with MSVC, it seems. My VS version is 16.11.10 and cl.exe is on version 19.29.30140.

This was the patch I applied to get it to compile again:

diff --git a/src/cip/CipString.h b/src/cip/CipString.h
index af5365c..1cdc713 100644
--- a/src/cip/CipString.h
+++ b/src/cip/CipString.h
@@ -6,6 +6,7 @@
 #define EIPSCANNER_CIP_STRINGS_H

 #include <cstring>
+#include <iterator>
 #include <string>
 #include <vector>
 #include "Types.h"
Broekman commented 2 years ago

Thanks for the update! I just added the missing include and merged the changes back.