xmemory0 Error When Trying to Build Project - c++

I'm developing some additional options for a game (which means I don't have knowledge about whole game's methods, classes etc.).
Anyway, I have been trying to build the project for codes I've developed to test them. I've encountered some DirectX, Windows SDK Version, Compiler problems but managed to solve them.
I've downloaded source codes through SVN, so whole project is actually working. I just couldn't manage to build it in my local laptop or desktop computer.
This time I'm getting xmemory0 error:
Code: C2280
Description: 'std::pair::pair(const std::pair &)':
attempting to reference a deleted function File: xmemory0 Line:840
Code part of the error is:
// xmemory0 internal header (from <memory>)
#pragma once
#ifndef _XMEMORY0_
#define _XMEMORY0_
#ifndef RC_INVOKED
#include <cstdint> /* for uintptr_t */
#include <cstdlib>
#include <limits>
#include <new>
#include <xutility>
#pragma pack(push,_CRT_PACKING)
#pragma warning(push,_STL_WARNING_LEVEL)
#pragma warning(disable: _STL_DISABLED_WARNINGS)
#pragma push_macro("new")
#undef new
... // other code lines
template<class _Objty,
class... _Types>
void construct(_Objty *_Ptr, _Types&&... _Args)
{ // construct _Objty(_Types...) at _Ptr
::new ((void *)_Ptr) _Objty(_STD forward<_Types>(_Args)...); // HERE IS GETTING ERROR
}
... // other code lines

Related

Sudden error compiling code for thr Arduino MKR WiFi 1010

The Question
Programming Arduino is something new to me - I've included what I believe is relevant, though please comment if more code/info is needed.
I'm creating a sketch that uses the ArduinoHttpClient library installed via the IDE's 'Manage Libraries' option.
Yesterday all was well - sketch compiles.
Today I get the error below. Nothing changed between yesterday and today that I can tell.
I have tried the code on other machines - 2 work, 1 doesn't and I cannot tell what is wrong and don't fully understand the actual error.
Can anybody explain a) what the error means and b) what i might be able to do to resolve it?
Code pieces
In file included from
/Users/me/Documents/Arduino/libraries/ArduinoHttpClient/src/ArduinoHttpClient.h:8:0,
from
/Users/me/Documents/Proj/network-comms/ard-mkr-wifi-1010/box_register.h:1,
from
/Users/me/Documents/Proj/network-comms/ard-mkr-wifi-1010/ard-mkr-wifi-1010.ino:11:
/Users/me/Documents/Arduino/libraries/ArduinoHttpClient/src/HttpClient.h:12:1:
error: expected ',' or ';' before 'static' static const int
HTTP_SUCCESS =0; ^~~~~~ exit status 1 Error compiling for board
Arduino MKR WiFi 1010.
The ArduinoHttpClient.h file is as installed and unchanged:
// Library to simplify HTTP fetching on Arduino
// (c) Copyright Arduino. 2016
// Released under Apache License, version 2.0
#ifndef ArduinoHttpClient_h
#define ArduinoHttpClient_h
#include "HttpClient.h"
#include "WebSocketClient.h"
#include "URLEncoder.h"
#endif
box_register.h at line one just includes the lib
#include <ArduinoHttpClient.h>
HttpClient.h from the Arduino lib is as - includes the line being reported:
// Class to simplify HTTP fetching on Arduino
// (c) Copyright MCQN Ltd. 2010-2012
// Released under Apache License, version 2.0
#ifndef HttpClient_h
#define HttpClient_h
#include <Arduino.h>
#include <IPAddress.h>
#include "Client.h"
static const int HTTP_SUCCESS =0; /// <------ LINE 11
// The end of the headers has been reached. This consumes the '\n'
// Could not connect to the server
static const int HTTP_ERROR_CONNECTION_FAILED =-1;
// This call was made when the HttpClient class wasn't expecting it
// to be called. Usually indicates your code is using the class
// incorrectly
static const int HTTP_ERROR_API =-2;
// Spent too long waiting for a reply
ard-mkr-wifi-1010.ino showing line including box_register
// va_start, va_end
#include <stdarg.h>
#include <WiFiNINA.h>
#include <PubSubClient.h>
#include <RTCZero.h>
#include <WiFiUdp.h>
#include <Wire.h>
#include "./arduino_secrets.h"
#include "./box_register.h" // <----- HERE
#include "./ntp.h"

vs2015 cuda9.0 linked SHA1_Init with CUDA implement instead of openssl cpu libs

I am a beginner to cuda, c++ and I am trying to move openssl sha1 cpu code to cuda c,but I ran into a weired problem.
here is the minimum code that can reproduce the problem.
There are three files in this vs2015 cuda9.0 project. They are main.cpp ,sha1.cu and sha1.h
//main.cpp
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include "openssl\sha.h"
int main()
{
SHA_CTX ctx;
SHA1_Init(&ctx);
return 0;
}
//sha1.h
#ifndef SHA1_H
#define SHA1_H
#include <stdint.h>
#include <cuda_runtime.h>
namespace cudatest {
#ifdef __cplusplus
extern "C" {
#endif
typedef struct
{
uint32_t state[5];
uint32_t count[2];
unsigned char buffer[64];
} SHA1_CTX;
#define SHA_CTX SHA1_CTX
#define SHA_DIGEST_LENGTH 20
__device__ void SHA1_Init(SHA1_CTX * context);
#ifdef __cplusplus
}
#endif
}
#endif /* SHA1_H */
//sha1.cu
#include <cuda_runtime.h>
#include "sha1.h"
namespace cudatest {
__device__ void SHA1_Init(SHA1_CTX * context)
{
}
}
The main.cpp uses C/C++ compiler and sha1.cu uses CUDA C/C++
And I add openssl headers into the AdditionalIncludeDirectories,set directory which contains ssleay32.lib and libeay32.lib to library path,set AdditionalDependencies with ssleay32.lib, libeay32.lib .
Then the project built with no error and no warning. But when I run it
or debug it,I found the function SHA1_Init runs into device code and
the program crashed immediately.
why the compiler linked function SHA1_Init with the cuda device
SHA1_Init implement which has a namespace cudatest wrapped instead
of a ssleay32.lib, libeay32.lib CPU implement?
OK,I found the problem.I shouldn't use extern "C" in a c++ namespace.It make the function visiable to the global namespace. if you define another c SHA1_Init function in a .cpp file ,the linker will complain.But if another SHA1_Init is in a openssl lib,the vs C/C++ linker warnned nothing but linked to the cuda implement.

"luaL_openlibs identifier not found", but all other luaL calls work (using C++ & lua library)

I am having trouble tracking down the source of this error because all other Lua appears to be compiling fine.
My scriptManager class is like so:
#include <luabind\lua_include.hpp>
//skip some
LuaScriptManager::LuaScriptManager()
{
state = luaL_newstate(); //is recognised fine
luaL_openlibs(state); //will not compile with this not commented
}
Luabind\lua_include.hpp is like so:
#ifndef LUABIND_CPLUSPLUS_LUA
extern "C"
{
#endif
#include "lua.h"
#include "lauxlib.h"
#include "luaconf.h"
#ifndef LUABIND_CPLUSPLUS_LUA
}
#endif
I don't believe I am missing any #include files that would apply to LuaL_openLibs. However, I didn't set up the lua files for this, someone else on the team did. Does anyone know any potential causes for this, or is my best bet to nuke it and set up the lua include files from scratch?

C++ compilation error when adding windows.h

I need to write small tool in C++
I've never used C++ as programming language before (I have couple years of Java dev experience) and .NET
I've started a new project in VS , when I am adding in my Header file of my class
#include <windows.h> I am getting the following error:
Error 1 error C2143: syntax error : missing ';' before '*' c:\program files\microsoft sdks\windows\v7.0a\include\servprov.h 96 1 CppLog
For now my class even doesn't have any real functions and looks like
in header
class TheTool
{
public :
void Foo();
};
in cpp
void TheTool::Foo(){};
and the project doesn't get compiled.
plz any suggestions ? Maybe a compiler doen't set up good ?
this is how the Header file looks like
#pragma once
#include "stdafx.h"
#include <stdio.h>
//#include <Windows.h>
//#include <winuser.h>
//#include <windowsx.h>
//#include <time.h>
class TheTool
{
public :
void Foo();
};
When I am uncommenting the include I am starting to get this compilation error.
BTW , how can i know the compiller setting ?

LNK2005, "already defined error" linker error in MSVC2010

I am trying to implement a test project using the Point Cloud Library and OpenCV with multiple files. When I try to compile, I get the "already defined error" message. Probably I'm doing something stupid that cannot realize for some reason - I tried out a couple of solutions found here, none of them seemed to be help in my case.
What I have:
A libs.h file, where I load the lib files (in Project properties, I only set up the .lib paths and load the libs "by hand", like the headers):
#pragma once
#ifndef PCLTEST_LIBS
#define PCLTEST_LIBS
#ifdef _DEBUG
#pragma comment(lib, "pcl_apps-gd.lib")
#pragma comment(lib, "pcl_common-gd.lib")
// a bunch of other debug libs
#else
// the release libs
#endif
#endif
A main file from which I basically deleted everything at this point to debug:
// load the libs
#ifndef PCLTEST_LIBS
#include "libs.h"
#endif
// pcltest includes
// if only this first one is #included, everything is OK
#include "opencvOperations.h"
// #including this one causes the error
#include "files.h"
// these ones are not working also
//#include "cloudOperations.h"
//#include "visualize.h"
// c++ headers
#include <stdio.h>
#include <string>
//#include <sstream>
//#include <iostream>
void writeInfo()
{
// some std::cout calls
}
int main( int argc, char* argv[] )
{
writeInfo();
// this function is in opencvOperations.h and works OK
pcltest::openLena();
}
Then I get several error messages in my main.obj that some (PCL related) symbols are already defined in files.obj. I use PCL related calls both in opencvOperations and files, the first one is OK, the second one does not work.
Edit:
To add more detail, my files.h header:
#pragma once
#ifndef PCLTEST_FILES
#define PCLTEST_FILES
// pcl headers
#ifndef PCL_COMMON_H_
#include <pcl/common/common_headers.h>
#endif
#ifndef PCL_IO_FILE_IO_H_
#include <pcl/io/file_io.h>
#endif
#ifndef PCL_IO_PCD_IO_H_
#include <pcl/io/pcd_io.h>
#endif
#ifndef PCL_IO_PLY_IO_H_
#include <pcl/io/ply_io.h>
#endif
// boost headers
#ifndef BOOST_FILESYSTEM_OPERATIONSX_HPP
#include <boost/filesystem/operations.hpp>
#endif
#endif
namespace pcltest
{
// function to open PCL or binary PLY files
pcl::PointCloud<pcl::PointXYZ>::Ptr openCloud(std::string filename);
// function to save the point cloud to PCD format
void saveCloud();
}
Before splitting the code into separate files, everything worked well (with the same project settings).
Edit2:
I located the source of the problem,
#include <pcl/io/ply_io.h>
causes this. For now, I got rid of everything related to PLY and everything works fine. I'll look at it later, this might be a PCL library specific issue. Still strange to me why this call causes linker error in an other file, where I don't even use PLY related functions/variables.
I had the same problem as you had. I had a surface.h and surface.cpp file, and I found out that I had to include the ply_io.h file from surface.cpp rather than surface.h and now it compiles fine. I hope that helps or makes sense! haha
If a constant is being instantiated in an include one can also use selectany, per http://msdn.microsoft.com/en-us/library/5tkz6s71%28v=vs.80%29.aspx -- in my case:
const int CSdata[] = {1, 2, 3, 4};
when included in more than one source part produces LNK2005 at link time, avoided via:
const __declspec(selectany) int CSdata[] = {1, 2, 3, 4};
Non-portable, yeah ...