boost geometry precision loss - c++

#include <iostream>
#include <vector>
#include <boost/geometry.hpp>
#include <boost/geometry/strategies/cartesian/distance_pythagoras.hpp>
#include <boost/geometry/geometries/point_xy.hpp>
#include <boost/geometry/geometries/polygon.hpp>
#include <boost/geometry/geometries/linestring.hpp>
#include <boost/geometry/multi/geometries/multi_polygon.hpp>
#include <boost/geometry/io/wkt/wkt.hpp>
#include <boost/foreach.hpp>
int main(int argc, char *argv[])
{
typedef boost::geometry::model::d2::point_xy<double> point;
typedef boost::geometry::model::polygon<point> polygon;
std::stringstream ss;
std::string sstring;
char *poly1 =
"POLYGON((45.4602851 9.1146293,45.4602851 9.1196293,45.4652851 9.1196293,45.4652851 9.1146293,45.4602851 9.1146293))";
char *buffer = NULL;
int poly1StrLen;
double tmp;
polygon poly, newPoly;
point p1;
boost::geometry::read_wkt(poly1, poly);
boost::geometry::correct(poly);
BOOST_FOREACH(point const & p, boost::geometry::exterior_ring(poly))
{
// ss << boost::geometry::wkt(p);
// p1.x(p.y());
// p1.y(p.x());
boost::geometry::append(boost::geometry::exterior_ring(newPoly), p);
}
ss << boost::geometry::wkt(newPoly);
sstring = ss.str();
buffer = (char *)malloc(sstring.length());
buffer = strcpy(buffer, sstring.c_str());
printf("%s\n", buffer);
free(buffer);
}
Result is :
POLYGON((45.4603 9.11463,45.4603 9.11963,45.4653 9.11963,45.4653 9.11463,45.4603 9.11463))
Is loosing too much precision for geo-coordinates, what I have to do to leave the same precision?

Just set the output precision on the stream, e.g.
std::cout << std::setprecision(12) << boost::geometry::wkt(newPoly);
This is a lot simpler. You don't have to do the whole buffer dance either!
Live On Coliru
#include <iostream>
#include <vector>
#include <boost/geometry.hpp>
#include <boost/geometry/geometries/point_xy.hpp>
#include <boost/geometry/geometries/polygon.hpp>
#include <boost/geometry/io/wkt/wkt.hpp>
#include <boost/foreach.hpp>
int main() {
typedef boost::geometry::model::d2::point_xy<double> point;
typedef boost::geometry::model::polygon<point> polygon;
char const *poly1 = "POLYGON((45.4602851 9.1146293,45.4602851 9.1196293,45.4652851 9.1196293,45.4652851 9.1146293,45.4602851 9.1146293))";
polygon poly, newPoly;
boost::geometry::read_wkt(poly1, poly);
boost::geometry::correct(poly);
BOOST_FOREACH(point const & p, boost::geometry::exterior_ring(poly)) {
boost::geometry::append(boost::geometry::exterior_ring(newPoly), p);
}
std::cout << std::setprecision(12) << boost::geometry::wkt(newPoly);
}
Prints
POLYGON((45.4602851 9.1146293,45.4602851 9.1196293,45.4652851 9.1196293,45.4652851 9.1146293,45.4602851 9.1146293))

Related

"extern vector<string> startParsing(FILE*);"

I'm learning C++, and I have the following problem. I can't understand how this sentence interacts
extern vector<string> startParsing(FILE*);
I tried to find information about (FILE*) but I can't find anything.
main.cpp
#include <iostream>
#include <fstream>
#include "Parser/parser.h"
using namespace std;
int main(int argc, char** argv)
{
cout<<"Welcome to Group 01 final project."<<endl;
std::string rule_file = "urbanmodel.zoo";
// parsing
Parser parser(rule_file);
std::vector<std::string> tokens = parser.parse();
parser.printTokens();
return 1;
}
parser.cpp
#include "parser.h"
extern vector<string> startParsing(FILE*); //<---------------------???
Parser::Parser(string filePath){
// open a file handle to a particular file:
this->myfile = fopen(filePath.c_str(), "r");
// make sure it's valid:
if (!this->myfile) {
cout << "I can't open the urbanmodel.zoo file!" << endl;
}
};
vector<string> Parser::parse(){
if(this->myfile)
this->tokens = startParsing(myfile);
return this->tokens;
};
void Parser::printTokens(){
int size = this->tokens.size();
for(int i=0;i<size;i++)
cout<<this->tokens[i];
cout<<std::endl;
};
parser.h
#include <iostream>
#include <vector>
#include <cstdio>
#include "scanner.h"
using namespace std;
class Parser{
private:
FILE* myfile; //<----------------------------------------???
vector<string> tokens;
public:
Parser(string filePath);
vector<string> parse();
void printTokens();
};

prepare for calling ParseAST. Fatal error

I'm reading the book Getting Started with LLVM Core Libraries and trying to implement an example from page 100 Chapter 4: Frontend. But got an error on the last line of code clang::ParseAST(CI.getSema());:
[bash#bash book]$ ./book_clang test.c
fatal error: error opening file '<invalid loc>':
What should I add to prepare for ParseAST?
code:
#include "llvm/ADT/IntrusiveRefCntPtr.h"
#include "llvm/Support/CommandLine.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Frontend/CompilerInstance.h"
#include "clang/Basic/TargetInfo.h"
#include "clang/Basic/TargetOptions.h"
#include "llvm/Support/Host.h"
#include <memory>
#include <string>
#include "clang/Basic/FileManager.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Lex/PreprocessorOptions.h"
#include "clang/Lex/Preprocessor.h"
#include "clang/AST/ASTConsumer.h"
#include "clang/Frontend/ASTConsumers.h"
#include "llvm/Support/raw_ostream.h"
#include "clang/Parse/ParseAST.h"
#include "clang/AST/ASTContext.h"
static llvm::cl::opt<std::string> fileName(llvm::cl::Positional, llvm::cl::desc("Input file"), llvm::cl::Required);
int main(int argc, char **argv)
{
llvm::cl::ParseCommandLineOptions(argc, argv, "My simple front end\n");
clang::CompilerInstance CI;
clang::DiagnosticOptions diagnosticOptions;
CI.createDiagnostics();
std::shared_ptr<clang::TargetOptions> PTO = std::make_shared<clang::TargetOptions>();
PTO->Triple = llvm::sys::getDefaultTargetTriple();
clang::TargetInfo *PTI = clang::TargetInfo::CreateTargetInfo(CI.getDiagnostics(), PTO);
CI.setTarget(PTI);
CI.createFileManager();//References getFileSystemOpts(), clang::vfs::getRealFileSystem(), hasVirtualFileSystem(), and setVirtualFileSystem().
CI.createSourceManager( CI.getFileManager());//References getDiagnostics().
CI.createPreprocessor(clang::TU_Complete);
CI.getPreprocessorOpts().UsePredefines = false;
std::unique_ptr< clang::ASTConsumer > astConsumer = clang::CreateASTPrinter(NULL, "");
CI.setASTConsumer(std::move(astConsumer));
CI.createASTContext();
CI.createSema(clang::TU_Complete, NULL);//after getASTConsumer(), getASTContext(), and getPreprocessor().
const clang::FileEntry *file = CI.getFileManager().getFile(fileName);
if (!file) {
llvm::errs() << "File not found: " << fileName;
return 1;
}
CI.getSourceManager().createFileID(file, clang::SourceLocation(), clang::SrcMgr::C_User);
CI.getDiagnosticClient().BeginSourceFile(CI.getLangOpts(), 0);
clang::ParseAST(CI.getSema());
// Print AST statistics
// CI.getASTContext().PrintStats();
// CI.getASTContext().Idents.PrintStats();
return 0;
}
for executable need to pass c-file, for example:
test.c
int main() {
char *msg = "Hello, world!\n";
write(1, msg, 14);
return 0;
}
the problem is solved. Need to set MainFileID for CompilerInstence's SourceManager
clang::FileID mainFileID = CI.getSourceManager().createFileID(file, clang::SourceLocation(), clang::SrcMgr::C_User);
CI.getSourceManager().setMainFileID(mainFileID);
The problem was that clang::ParseAST calls (S is Sema) S.getPreprocessor().EnterMainSourceFile(); that calls SourceMgr.getMainFileID();
void Preprocessor::EnterMainSourceFile() {
assert(NumEnteredSourceFiles == 0 && "Cannot reenter the main file!");
FileID MainFileID = SourceMgr.getMainFileID();
But MainFileID was'n set
corrected full code is:
#include "llvm/Support/CommandLine.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Frontend/CompilerInstance.h"
#include "clang/Basic/TargetInfo.h"
#include "clang/Basic/TargetOptions.h"
#include "llvm/Support/Host.h"
#include <memory>
#include <string>
#include "clang/Basic/FileManager.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Lex/PreprocessorOptions.h"
#include "clang/Lex/Preprocessor.h"
#include "clang/AST/ASTConsumer.h"
#include "clang/Frontend/ASTConsumers.h"
#include "llvm/Support/raw_ostream.h"
#include "clang/Parse/ParseAST.h"
#include "clang/AST/ASTContext.h"
static llvm::cl::opt<std::string> fileName(llvm::cl::Positional, llvm::cl::desc("Input file"), llvm::cl::Required);
int main(int argc, char **argv)
{
llvm::cl::ParseCommandLineOptions(argc, argv, "My simple front end\n");
clang::CompilerInstance CI;
clang::DiagnosticOptions diagnosticOptions;
CI.createDiagnostics();
std::shared_ptr<clang::TargetOptions> PTO = std::make_shared<clang::TargetOptions>();
PTO->Triple = llvm::sys::getDefaultTargetTriple();
clang::TargetInfo *PTI = clang::TargetInfo::CreateTargetInfo(CI.getDiagnostics(), PTO);
CI.setTarget(PTI);
CI.createFileManager();//References getFileSystemOpts(), clang::vfs::getRealFileSystem(), hasVirtualFileSystem(), and setVirtualFileSystem().
CI.createSourceManager( CI.getFileManager());//References getDiagnostics().
CI.createPreprocessor(clang::TU_Complete);
CI.getPreprocessorOpts().UsePredefines = false;
std::unique_ptr< clang::ASTConsumer > astConsumer = clang::CreateASTPrinter(NULL, "");
CI.setASTConsumer(std::move(astConsumer));
CI.createASTContext();
CI.createSema(clang::TU_Complete, NULL);//after getASTConsumer(), getASTContext(), and getPreprocessor().
const clang::FileEntry *file = CI.getFileManager().getFile(fileName);
if (!file) {
llvm::errs() << "File not found: " << fileName;
return 1;
}
clang::FileID mainFileID = CI.getSourceManager().createFileID(file, clang::SourceLocation(), clang::SrcMgr::C_User);
CI.getSourceManager().setMainFileID(mainFileID);
CI.getDiagnosticClient().BeginSourceFile(CI.getLangOpts(), 0);
clang::ParseAST(CI.getSema());
// Print AST statistics
CI.getASTContext().PrintStats();
CI.getASTContext().Idents.PrintStats();
return 0;
}

XDR serializing variable lenght array of string

I am serializing a packet over XDR but i do not understand how to provide vector of string. I have here a small fully working serialization / deserialization for a std::vector of uint64_t. Here my code:
Serializer:
#include <stdio.h>
#include <iostream>
#include <rpc/rpc.h>
#include <vector>
#define MAX_LENGTH_ 100
int main(void)
{
XDR xdr;
xdrstdio_create(&xdr, stdout, XDR_ENCODE);
std::vector<uint64_t> ids; // vector i want to send
ids.push_back(1);
ids.push_back(2);
ids.push_back(3);
// serializing the vector
uint64_t *_ids = &ids[0];
uint32_t size = ids.size();
xdr_array(&xdr,(char**)(&_ids), &size, MAX_LENGTH_,sizeof(uint64_t),(xdrproc_t)xdr_u_long);
return 1;
}
Deserializer:
#include <stdio.h>
#include <iostream>
#include <rpc/rpc.h>
#include <vector>
#define MAX_LENGTH_ 100
int main(void)
{
XDR xdrs;
xdrstdio_create(&xdrs, stdin, XDR_DECODE);
uint64_t *ids_ = new uint64_t[MAX_LENGTH_];
uint32_t size;
bool status = xdr_array(&xdrs,(char**)(&ids_), &size, MAX_LENGTH_,
sizeof(uint64_t), (xdrproc_t)xdr_u_long);
std::vector<uint64_t> ids(ids_,ids_+size);
for(std::vector<uint64_t>::iterator it = ids.begin(); it != ids.end(); ++it)
{
std::cout << *it <<std::endl;
}
return 1;
}
The following code works... running ./serializer | ./deserializer i obtain 1 2 3. Now I do not know how to handle having to serialize std::vector<std::string>. A single string works well using xdr_string.
http://linux.die.net/man/3/xdr_array
Any help would be very much appreciated!
EDIT:
I have tried the following:
Serializer:
#include <stdio.h>
#include <iostream>
#include <rpc/rpc.h>
#include <vector>
#include <algorithm>
#include <cstring>
#define MAX_VECTOR_LENGTH_ 100
#define MAX_STRING_LENGTH_ 50
char *convert(const std::string & s)
{
char *pc = new char[s.size()+1];
std::strcpy(pc, s.c_str());
return pc;
}
int main(void)
{
XDR xdr;
xdrstdio_create(&xdr, stdout, XDR_ENCODE);
std::vector<std::string> messages; // vector i want to send
messages.push_back("this is");
messages.push_back("my string");
messages.push_back("vector test");
// transform the vector to c style
std::vector<char*> messagesCStyle;
std::transform(messages.begin(), messages.end(), std::back_inserter(messagesCStyle), convert);
// serializing the vector
char **_messages = &messagesCStyle[0];
uint32_t size = messages.size();
xdr_array(&xdr,(char**)(&_messages), &size, MAX_VECTOR_LENGTH_ * MAX_STRING_LENGTH_,sizeof(char),(xdrproc_t)xdr_string);
return 1;
}
Deserializer:
#include <stdio.h>
#include <iostream>
#include <rpc/rpc.h>
#include <vector>
#define MAX_VECTOR_LENGTH_ 100
#define MAX_STRING_LENGTH_ 50
int main(void)
{
XDR xdrs;
xdrstdio_create(&xdrs, stdin, XDR_DECODE);
std::vector<char*> messagesCStyle_;
uint32_t size;
bool status = xdr_array(&xdrs,(char**)(&messagesCStyle_), &size, MAX_VECTOR_LENGTH_,
MAX_STRING_LENGTH_, (xdrproc_t)xdr_string);
for(std::vector<char*>::iterator it = messagesCStyle_.begin(); it != messagesCStyle_.end(); ++it)
{
std::cout << *it <<std::endl;
}
return 1;
}
I am pretty sure the code for the Serializer is not best but at least it seams to work. However the deserializer does not!! I think the problem is related to the fact that i do not know how much memory to allocate before calling the xdr_array. Any help?
I made it work:
Encoder:
#include <stdio.h>
#include <iostream>
#include <rpc/rpc.h>
#include <vector>
#include <algorithm>
#include <cstring>
#define MAX_VECTOR_LENGTH_ 100
#define MAX_STRING_LENGTH_ 50
char *convert(const std::string & s)
{
char *pc = new char[s.size()+1];
std::strcpy(pc, s.c_str());
return pc;
}
int main(void)
{
XDR xdr;
xdrstdio_create(&xdr, stdout, XDR_ENCODE);
std::vector<std::string> messages; // vector i want to send
messages.push_back("this is");
messages.push_back("my string");
messages.push_back("vector test");
messages.push_back("this is a relatively long string!!!");
// transform the vector to c style
std::vector<char*> messagesCStyle;
std::transform(messages.begin(), messages.end(),
std::back_inserter(messagesCStyle),
[](const std::string & s){
char *pc = new char[s.size()+1];
std::strcpy(pc, s.c_str());
return pc;
});
// serializing the vector
char **_messages = &messagesCStyle[0];
uint32_t size = messages.size();
xdr_array(&xdr,(char**)(&_messages), &size, MAX_VECTOR_LENGTH_ * MAX_STRING_LENGTH_,sizeof(char*),(xdrproc_t)xdr_string);
return 1;
}
Decoder:
#include <stdio.h>
#include <iostream>
#include <rpc/rpc.h>
#include <vector>
#define MAX_VECTOR_LENGTH_ 100
#define MAX_STRING_LENGTH_ 50
int main(void)
{
XDR xdrs;
uint32_t size;
char** buffer = NULL;
xdrstdio_create(&xdrs, stdin, XDR_DECODE);
bool status = xdr_array(&xdrs, (char**) &buffer, &size, MAX_VECTOR_LENGTH_,
sizeof(char*), (xdrproc_t)xdr_string);
std::cout << "status: " << status << std::endl;
std::cout << "size: " << size << std::endl;
std::vector<std::string> stringMessages_(buffer, buffer + size);
for(std::vector<std::string>::iterator it = stringMessages_.begin(); it != stringMessages_.end(); ++it)
{
std::cout << *it <<std::endl;
}
for (int i = 0; i < size; i++) {
free(buffer[i]);
}
free(buffer);
return 1;
}

Simultaneous CGAL calculations in multiple threads

I'm trying to run multiple geometric calculations with CGAL simultaneously in multiple threads. All threads are 100% "isolated" from each other. Nevertheless the app crashes with an access violation:
http://s8.postimg.org/52u9qphdx/error.png
I've build a small example app to reproduce the error:
main.cpp
#include <fstream>
#include "windows.h"
#include "cTestClass.h"
int main ( int argc, char *argv[] ){
cTestClass *eval0 = new cTestClass("d://.partion_2.stl", 0);
cTestClass *eval1 = new cTestClass("d://.partion_2.stl", 1);
eval0->start_eval();
eval1->start_eval();
while (!eval0->eval_finished())
{
Sleep(200);
}
while (!eval1->eval_finished())
{
Sleep(200);
}
return EXIT_SUCCESS;
}
cTestClass.h
#ifndef CTEST_CLASS_H
#define CTEST_CLASS_H
#include <atomic>
#include <thread>
class cTestClass
{
private:
std::atomic<bool> flag_eval_finished;
std::thread eval_thread;
std::string stl_file_name;
unsigned int thread_index;
cTestClass(){ }
void evaluate_partition();
public:
cTestClass(std::string argStlFile, unsigned int argThread_index);
void start_eval();
bool eval_finished();
};
#endif
cTestClass.cpp
#include "cTestClass.h"
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
#include <CGAL/Polyhedron_3.h>
#include <CGAL/Nef_polyhedron_3.h>
#include <CGAL/polygon_soup_to_polyhedron_3.h>
#include <CGAL/IO/Polyhedron_builder_from_STL.h>
#include <iostream>
#include <fstream>
//typedef CGAL::Cartesian<double> Kernel;
typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel;
typedef CGAL::Polyhedron_3<Kernel> Polyhedron_3;
typedef CGAL::Nef_polyhedron_3<Kernel> Nef_polyhedron_3;
typedef CGAL::Point_3<Kernel> Point_3;
//typedef Polyhedron::Point_iterator Point_iterator;
typedef Polyhedron_3::Vertex_iterator Vertex_iterator;
typedef Polyhedron_3::Facet_iterator Facet_iterator;
typedef Polyhedron_3::Halfedge_around_facet_circulator Halfedge_facet_circulator;
typedef Nef_polyhedron_3::Volume_const_iterator Volume_const_iterator;
typedef Kernel::Iso_cuboid_3 Iso_cuboid;
//constructor
cTestClass::cTestClass(std::string argStlFile, unsigned int argThread_index)
{
thread_index = argThread_index;
stl_file_name = argStlFile;
flag_eval_finished = false;
}
//===========================================================================================
// public member functions
void cTestClass::start_eval()
{
std::cout << "Thread " << thread_index << ": start" << std::endl;
eval_thread = std::thread(&cTestClass::evaluate_partition, this);
}
bool cTestClass::eval_finished()
{
return flag_eval_finished;
}
//===========================================================================================
//private member functions
void cTestClass::evaluate_partition()
{
//read stl file and create cgal polyhedron
Polyhedron_3 poly_Partition;
std::ifstream stl_file(stl_file_name.c_str(), std::ifstream::in);
std::vector<CGAL::cpp11::array<double, 3> > points;
std::vector<CGAL::cpp11::array<int, 3> > triangles;
CGAL::read_STL(stl_file, points, triangles);
stl_file.close();
//create polyhedron
CGAL::polygon_soup_to_polyhedron_3(poly_Partition, points, triangles);
//convert polyhedron to nef_poly representation
std::cout << "Thread " << thread_index << ": " <<"Converting partition polyhedron to Nef representation" << std::endl;
Nef_polyhedron_3 nefpoly_Partition(poly_Partition);
flag_eval_finished = true;
}
Anyone got an idea what causes this crash?
Best regards
Monchi

vector<wstring> as Return value and Parameter

I want to create some modules for my program. I want to call a function and pass a vector as a parameter. The return value should also be a vector.
My code looks like this
main.cpp
//BlueSmart.cpp : Definiert den Einstiegspunkt für die Konsolenanwendung.
#include "stdafx.h"
#define WIN32_LEAN_AND_MEAN
using namespace std;
#pragma comment(lib, "Irprops.lib")
BLUETOOTH_FIND_RADIO_PARAMS m_bt_find_radio = {
sizeof(BLUETOOTH_FIND_RADIO_PARAMS)
};
BLUETOOTH_RADIO_INFO m_bt_info = {
sizeof(BLUETOOTH_RADIO_INFO),
0,
};
BLUETOOTH_DEVICE_SEARCH_PARAMS m_search_params = {
sizeof(BLUETOOTH_DEVICE_SEARCH_PARAMS),
1,
0,
1,
1,
1,
15,
NULL
};
BLUETOOTH_DEVICE_INFO m_device_info = {
sizeof(BLUETOOTH_DEVICE_INFO),
0,
};
HANDLE m_radio = NULL;
HBLUETOOTH_RADIO_FIND m_bt = NULL;
HBLUETOOTH_DEVICE_FIND m_bt_dev = NULL;
int wmain(int argc, wchar_t **args) {
while(true) {
m_bt = BluetoothFindFirstRadio(&m_bt_find_radio, &m_radio);
do {
localBluetoothDevices ();
m_search_params.hRadio = m_radio;
::ZeroMemory(&m_device_info, sizeof(BLUETOOTH_DEVICE_INFO));
m_device_info.dwSize = sizeof(BLUETOOTH_DEVICE_INFO);
m_bt_dev = BluetoothFindFirstDevice(&m_search_params, &m_device_info);
vector<wstring> vec;
int m_device_id = 0;
do {
wostringstream tmp;
++m_device_id;
//Something like this <----------------------------------------
externBluetoothDevices (vec);
//Something like this <----------------------------------------
wprintf(L"********************************************************************** \n");
wprintf(L"\tDevice %d:\r\n", m_device_id);
wprintf(L"\t\tName: %s\r\n", m_device_info.szName);
wprintf(L"\t\tAddress: %02x:%02x:%02x:%02x:%02x:%02x\r\n", m_device_info.Address.rgBytes[0], m_device_info.Address.rgBytes[1], m_device_info.Address.rgBytes[2], m_device_info.Address.rgBytes[3], m_device_info.Address.rgBytes[4], m_device_info.Address.rgBytes[5]);
wprintf(L"====================================================================== \n");
for (int i = 0; i < 6; i++) {
tmp << hex << m_device_info.Address.rgBytes [i];
if (i < 5)
tmp << L':';
}
vec.push_back(tmp.str());
} while(BluetoothFindNextDevice(m_bt_dev, &m_device_info));
BluetoothFindDeviceClose(m_bt_dev);
//Sleep(10*1000*60);
Sleep(10000);
} while(BluetoothFindNextRadio(&m_bt_find_radio, &m_radio));
BluetoothFindRadioClose(m_bt);
}
return 0;
}
//Lokal verfügbare bzw. angeschlossene Bluetooth-Devices
void localBluetoothDevices (){
int m_radio_id = 0;
m_radio_id++;
BluetoothGetRadioInfo(m_radio, &m_bt_info);
//Lokaler Bluetoothadapter
wprintf(L"====================================================================== \n");
wprintf(L"Local Device Nr. %d\n", m_radio_id);
wprintf(L"\tName: %s\r\n", m_bt_info.szName);
wprintf(L"\tAddress: %02x:%02x:%02x:%02x:%02x:%02x\r\n", m_bt_info.address.rgBytes[0], m_bt_info.address.rgBytes[1], m_bt_info.address.rgBytes[2], m_bt_info.address.rgBytes[3], m_bt_info.address.rgBytes[4], m_bt_info.address.rgBytes[5]);
}
//Extern verfügbare bzw. Bluetooth-Devices
vector<wstring> externBluetoothDevices (vector<wstring> &vec){
return vec;
}
stdafx.h
#pragma once
#include "targetver.h"
#include <stdio.h>
#include <tchar.h>
#include <winsock2.h>
#include <windows.h>
#include <stdlib.h>
#include <bthdef.h>
#include <BluetoothAPIs.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <iomanip>
#include <conio.h>
void localBluetoothDevices ();
vector<wstring> externBluetoothDevices (vector<wstring>);
It says that vector is not a known type. What am I doing wrong?
In stdafx.h replace
vector<wstring> externBluetoothDevices (vector<wstring>);
with
std::vector<std::wstring> externBluetoothDevices (std::vector<std::wstring>);
Basically the issue was although you put using namespace std; in your cpp file that doesn't count in your header file which is before the using declaration is seen.
Also note that your defintion in the cpp file is different. In the cpp file you have a reference
vector<wstring> externBluetoothDevices (vector<wstring>&);
Decide which you really want.
You should pass a pointer of a vector.