0

My colleague who uses Linux ran the same code as me, however, it compiled and ran perfectly for him.

I am pretty new to using C++ and Visual Studio(latest version) so this might be silly. I have the following code in a header file

#pragma once
#include<set>
#include<deque>
#include <vector>
using namespace std;

enum Sign { lnone, lpos, lneg, lboth};
class Literal
{
public:
    Sign sign;
    int vneg;
    int vpos;
    Literal() = default;
    ~Literal() = default;
    Literal(Sign s, int b,int c)
    {
         sign=s;
         vneg = b;
         vpos = c;
    }
};
typedef deque<Literal>Clause;
typedef set<Clause>Formula;
typedef deque<int> Row;
typedef vector<Row> Matrix;
extern Matrix posT;
extern Matrix negT;
extern Formula f;

When I now try to build, it shows Build failed with the following errors:

C2672: 'operator_surrogate-func' no matching overloading function found

C2893: Failed to specialize function template 'unknown-type std::less::operator ()(_Ty1 &&,_Ty2 &&) noexcept() const'

C2672: 'operator_surrogate-func' no matching overloading function found

C2893: Failed to specialize function template 'unknown-type std::less::operator ()(_Ty1 &&,_Ty2 &&) noexcept() const'

in different lines of the xuitlity file

Can someone point me in the right direction, please?

  • All c++ programs need a startup function. Here is what the c++ standard says about that: [https://en.cppreference.com/w/cpp/language/main_function](https://en.cppreference.com/w/cpp/language/main_function) – drescherjm Sep 16 '22 at 13:44
  • On MS Windows there may be a few different options than just int main() depending on the type of project: [https://stackoverflow.com/questions/416739/difference-between-winmain-main-and-dllmain-in-c](https://stackoverflow.com/questions/416739/difference-between-winmain-main-and-dllmain-in-c) – drescherjm Sep 16 '22 at 13:48
  • Is that true even for header files? – Darth jedi Sep 16 '22 at 13:50
  • If you make any type of executable project it needs a startup function and at least 1 source file. – drescherjm Sep 16 '22 at 13:51
  • However, even if I include the CPP file I am running which includes a main function it still shows the same error – Darth jedi Sep 16 '22 at 13:54
  • My guess in that case is the cpp file is not part of the Visual Studio project. Not listed in "Solution Explorer" as part of the project. Being in the same folder is no help. – drescherjm Sep 16 '22 at 13:58
  • It is in fact in the solution explorer part of the project – Darth jedi Sep 16 '22 at 14:03
  • Maybe you have a project that needs a different signature. Or maybe you did something wrong with where you placed your `int main()` the main function must be in the global namespace and not part of class or some other namespace. – drescherjm Sep 16 '22 at 14:06
  • The function is indeed in the global namespace. However I am not familiar with signature of the project – Darth jedi Sep 16 '22 at 14:13

0 Answers0