lundi 18 février 2019

gtest/Google Test C++ build error on Visual Studio 2017

I am trying to build a simple test using gtest on the latest version of Visual Studio 2017. The code is the following:

#include "pch.h"
#include <gtest/gtest.h>

struct BankAccount
{
    int balance = 0;

    BankAccount()
    {
    }

    explicit BankAccount(const int balance)
        : balance{ balance }
    {
    }
};

TEST(AccountTest, BankAccountStartsEmpty)
{
    BankAccount account;
    EXPECT_EQ(0, account.balance);
}


int main(int argc, char* argv[])
{
    testing::InitGoogleTest(&argc, argv);
    return RUN_ALL_TESTS();
}

And the build error is:

 Error  C4996   'std::tr1': warning STL4002: The non-Standard std::tr1 namespace and TR1-only machinery are deprecated and will be REMOVED. 
You can define _SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING to acknowledge that you have received this warning.

I already tried:

#define _SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING

But it just makes things worse. I dont know how to fix this error.

Aucun commentaire:

Enregistrer un commentaire