Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Errors when building 2.12.0 on Visual Studio 2017 #257

Open
madebr opened this issue Aug 9, 2020 · 1 comment
Open

Errors when building 2.12.0 on Visual Studio 2017 #257

madebr opened this issue Aug 9, 2020 · 1 comment

Comments

@madebr
Copy link

madebr commented Aug 9, 2020

Hello,

I'm trying to package ossim 2.12.0 for conan at conan-io/conan-center-index#2459

Using Visual Studio, building a static ossim fails with the following error:

Severity	Code	Description	Project	File	Line	Suppression State
Error	C2666	'ossimString::operator !=': 2 overloads have similar conversions	ossim	C:\Users\maarten\.conan\data\ossim\2.12.0\_\_\build\5bdfed110172ecef3a963112a861792e242d368e\source_subfolder\src\base\ossimFilename.cpp	1132	
Error	C2666	'ossimString::operator ==': 4 overloads have similar conversions	ossim	C:\Users\maarten\.conan\data\ossim\2.12.0\_\_\build\5bdfed110172ecef3a963112a861792e242d368e\source_subfolder\src\support_data\ossimNitfRsmecbTag.cpp	266	

The 4 operator== overloads about which the compiler complains are:

   friend OSSIM_DLL bool operator==(const char* lhs, const ossimString& rhs);
   friend OSSIM_DLL bool operator==(const std::string& lhs, const ossimString& rhs);
   bool operator==(const ossimString& rhs) const;
   bool operator==(const char* rhs) const;

The 2 operator!= overloads about which the compiler complains are:

   bool operator!=(const ossimString& rhs) const;
   bool operator!=(const char* rhs) const;
@madebr
Copy link
Author

madebr commented Dec 2, 2020

This patch fixed my problem:

--- include/ossim/base/ossimString.h
+++ include/ossim/base/ossimString.h
@@ -235,7 +235,7 @@ public:
    }

    /**
-    *  @brief  Test if this ossimString is equal to a C sting.
+    *  @brief  Test if this ossimString is equal to a C string.
     *  @param rhs C string to compare.
     *  @return  True if strings are equal.
     *  False if rhs is not equal null or null.
@@ -250,6 +250,22 @@ public:
       return result;
    }

+   /**
+    *  @brief  Test if this ossimString is equal to character.
+    *  @param rhs character to compare.
+    *  @return  True if strings are equal.
+    *  False if rhs is not equal null or null.
+    */
+   bool operator==(char rhs) const
+   {
+      bool result = false;
+      if (rhs)
+      {
+         result = (m_str.compare(std::string(1, rhs)) == 0);
+      }
+      return result;
+   }
+
    /**
     *  @brief  Test if this ossimString is not equal to another ossimString.
     *  @param rhs ossimString to compare.
@@ -261,7 +277,7 @@ public:
    }

    /**
-    *  @brief  Test if this ossimString is not equal to a C sting.
+    *  @brief  Test if this ossimString is not equal to a C string.
     *  @param rhs C string to compare.
     *  @return  True if strings are not equal or rhs is null.
     *  False if rhs equal to this string.
@@ -276,6 +292,16 @@ public:
       return result;
    }

+   /**
+    *  @brief  Test if this ossimString is not equal to a char.
+    *  @param ch character to compare.
+    *  @return  True if char is not equal.  False otherwise.
+    */
+   bool operator!=(char rhs) const
+   {
+       return !(m_str.compare(std::string(1, rhs)) == 0);
+   }
+
    bool operator<(const ossimString& rhs) const
    {
       return m_str < rhs.m_str;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant