stl copy () iterator: binary '>>' : no operator found - stl

Here I have a basic example from a pdf on STL.
Why doesn't it work?
#include "stdafx.h"
#include <vector>
#include <algorithm>
#include <iostream>
#include <iterator>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
vector<string> coll;
copy(istream_iterator<string>(cin), //start of source
istream_iterator<string>(), //end of source
back_inserter(coll));
return 0;
}
errors:
ClCompile: All outputs are up-to-date.
stl_testing1.cpp
c:\program files\microsoft visual studio 10.0\vc\include\iterator(470): error C2678: binary '>>' :
no operator found which takes a left-hand operand of type 'std::basic_istream<_Elem,_Traits>' (or there is no acceptable conversion)
with
[
_Elem=char,
_Traits=std::char_traits<char>
]
c:\program files\microsoft visual studio 10.0\vc\include\istream(1053): could be 'std::basic_istream<_Elem,_Traits> &std::operator
>><std::char_traits<char>>(std::basic_istream<_Elem,_Traits> &&,signed char *)'
with
[
_Elem=char,
_Traits=std::char_traits<char>
]
c:\program files\microsoft visual studio 10.0\vc\include\istream(1060): or 'std::basic_istream<_Elem,_Traits> &std::operator
>><std::char_traits<char>>(std::basic_istream<_Elem,_Traits> &&,signed char &)'
with
[
_Elem=char,
_Traits=std::char_traits<char>
]
c:\program files\microsoft visual studio 10.0\vc\include\istream(1067): or 'std::basic_istream<_Elem,_Traits> &std::operator
>><std::char_traits<char>>(std::basic_istream<_Elem,_Traits> &&,unsigned char *)'
with
I wonder what is wrong. This is a Win32 console application.

#include <string>
This might help.

Related

Memory mapping in Octave with mex-functions

I have a plain C code (running on Linux) and I would like to implement it in Octave, so I thought I could use a mex-file for handling the memory mapping and send the information I received (or send) back and forth to my script in Octave and my sensors. The C code looks like this:
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <poll.h>
#include <fcntl.h>
#include <errno.h>
#include <unistd.h>
#include <sys/mman.h>
#define CUSTOM_IP_MAP_SIZE 0x10000
#define CUSTOM_IP_BASEADDR 0x43C00000
#define CUSTOM_IP_S00_AXI_SLV_REG0_OFFSET 0
#define CUSTOM_IP_S00_AXI_SLV_REG1_OFFSET 4
int main(void)
{
uint32_t leds=0x0;
int fd = open("/dev/uio0", O_RDWR);
void *ptr;
if (fd < 0) {
perror("open");
exit(EXIT_FAILURE);
}
ptr = mmap(NULL, CUSTOM_IP_MAP_SIZE, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
while (1) {
leds = *((unsigned *)(ptr + CUSTOM_IP_S00_AXI_SLV_REG1_OFFSET)); //Read from the IP (slv_reg1).
*((unsigned *)(ptr + CUSTOM_IP_S00_AXI_SLV_REG0_OFFSET)) = leds; //Write to the IP (slv_reg0).
}
close(fd);
exit(EXIT_SUCCESS);
}
I compiled the code with no errors and the following command:
mkoctfile --mex mmap.c
I get the following error when I run it in Octave:
error: failed to install .mex file function 'mmap'
Should I keep trying to do this with a mex-function or there is other option better for this?
Thank you for any help.

mysqlcppconn.dll Cannot find or open the PDB file

I am trying to build a simple MySQL db application in VC++ and have run into a slight problem.
I am using MySQL Connector C++ 1.1.0 and Visual Studio 2012 (Premium if that matters)
// ConsoleApplication1.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <sstream>
#include <memory>
#include <string>
#include <stdexcept>
/* MySQL Connector/C++ specific headers */
#include <driver.h>
#include <connection.h>
#include <statement.h>
#include <prepared_statement.h>
#include <resultset.h>
#include <metadata.h>
#include <resultset_metadata.h>
#include <exception.h>
#include <warning.h>
#include "mysql_driver.h"
#include "mysql_connection.h"
#define DBHOST "tcp://127.0.0.1:3306"
#define USER "root"
#define PASSWORD "root"
#define DATABASE "test"
using namespace std;
using namespace sql;
int _tmain(int argc, char *argv[]){
// I'm alive
cout << "Hello World!" << endl;
// necessary variables
Driver *driver;
Connection* con;
Statement *stmt;
ResultSet *res;
/*PreparedStatement *prep_stmt;
Savepoint *savept;*/
//
driver = get_driver_instance();
// Connect to DB
con = driver->connect("tcp//127.0.0.1:3306", "root", "root");
//
con->setAutoCommit(false);
// set schema
con->setSchema("world");
// create statement object
stmt = con->createStatement();
// alert user
cout << "Executing query: \"SELECT * FROM city\"" << endl;
// execute query "SELECT * FROM city"
res = stmt->executeQuery("SELECT * FROM city");
// alert user
cout << "\tRetrieved " << res->rowsCount() << " row(s)." << endl;
// fetch data
while(res->next()){
cout << res->getString("Name") << endl;
}
system("pause");
// Clean up
delete res;
delete stmt;
/*delete prep_stmt;*/
con->close();
delete con;
return 0;
} // end main
I am building this as a Win32 console application in Debug mode, changed the configuration to x64 and have moved mysqlcppconn.dll to the output directory.
The code is building correctly (*I think I have correctly added the necessary include directories as well as additional library dependencies/relevant paths). However, when I try to run it I get the following debug output:
'ConsoleApplication1.exe' (Win32): Loaded 'C:\Users\RBanerjee\Documents\Visual Studio 2012\Projects\ConsoleApplication1\x64\Debug\ConsoleApplication1.exe'. Symbols loaded.
'ConsoleApplication1.exe' (Win32): Loaded 'C:\Windows\System32\ntdll.dll'. Symbols loaded.
'ConsoleApplication1.exe' (Win32): Loaded 'C:\Windows\System32\kernel32.dll'. Symbols loaded.
'ConsoleApplication1.exe' (Win32): Loaded 'C:\Windows\System32\KernelBase.dll'. Symbols loaded.
'ConsoleApplication1.exe' (Win32): Loaded 'C:\Users\RBanerjee\Documents\Visual Studio 2012\Projects\ConsoleApplication1\x64\Debug\mysqlcppconn.dll'. Cannot find or open the PDB file.
'ConsoleApplication1.exe' (Win32): Loaded 'C:\Windows\System32\libmysql.dll'. Module was built without symbols.
'ConsoleApplication1.exe' (Win32): Unloaded 'C:\Windows\System32\libmysql.dll'
'ConsoleApplication1.exe' (Win32): Loaded 'C:\Windows\System32\libmysql.dll'. Module was built without symbols.
'ConsoleApplication1.exe' (Win32): Unloaded 'C:\Windows\System32\libmysql.dll'
The program '[4172] ConsoleApplication1.exe' has exited with code -1073741701 (0xc000007b).
I am a little lost as to what to do next, I really just want to be able to develop a Windows application that can connect to a MySQL db and interact with it. I would appreciate any help with this problem or a pointer to some other tutorial.
Thanks
Rohit

cuda Texture declaration compile-time error

I'm trying to compile the following piece of code:
#include <stdio.h>
#include <time.h>
#include <cuda.h>
#include <cuda_runtime_api.h>
texture<float, 2, cudaReadModeElementType> tex;
int main () { ... }
yet, nvcc gives me the following error:
main.c:6:8: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘<’ token
I'm pretty new to CUDA, so I suppose I'm missing something here.
You can only use CUDA syntax in .cu files.

C++ Builder STL for OS X fails?

Has anybody tried something as simple as #include <vector> in an application for the Mac compiled with XE2?
Is something so basic broken in XE2 update 1 for C++ Builder or is my install broken?
Simply adding #include <vector> to a new fire monkey HD app, I get build failures:
[BCC32 Error] cstdlib(43): E2015 Ambiguity between 'ldiv_t' and 'Posix::Stdlib::ldiv_t'
Full parser context
Unit1.cpp(7): #include C:\Program Files\Embarcadero\RAD Studio\9.0\include\boost_1_39\boost\tr1\tr1\vector
vector(16): #include C:\Program Files\Embarcadero\RAD Studio\9.0\include\boost_1_39\boost/tr1/detail/config_all.hpp
config_all.hpp(48): #include c:\program files\embarcadero\rad studio\9.0\include\dinkumware\cstdlib
cstdlib(32): namespace std
From the code:
//---------------------------------------------------------------------------
#include <fmx.h>
#pragma hdrstop
#include "Unit1.h"
#include <vector>
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.fmx"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
Solution from Embarcadero (this is for update 2 only):
Open cstdlib in the [RADStudioXE2]\include\dinkumware directory
Take line 49: using _CSTD size_t; using _CSTD div_t; using _CSTD ldiv_t;
Move it above the "#if defined" block right above it (line 33)
The STL can now be compiled into an FMX C++ application
try removing $(CG_BOOST_ROOT) from your include paths.

CUDA: Error while compiling my first cuda program

I am very new to CUDA programming.. I wrote my first code and when I compiled it, it is showing me a lots of error. Can anyone tell me what is wrong
the code
#include <stdio.h>
#include "cuda.h"
#include <stdlib.h>
__global__ void kernel(void) {
}
int main(int argc, char *argv[])
{
kernel<<<1,1>>>();
printf("finished \n");
return 0;
}
The errors are
cuda.c:5: error: expected â=â, â,â, â;â, âasmâ or â__attribute__â before âvoidâ
cuda.c:7: error: expected â=â, â,â, â;â, âasmâ or â__attribute__â before âvoidâ
cuda.c: In function âmainâ:
cuda.c:12: error: âkernelâ undeclared (first use in this function)
cuda.c:12: error: (Each undeclared identifier is reported only once
cuda.c:12: error: for each function it appears in.)
cuda.c:12: error: expected expression before â<â token
I compiled using
nvcc cuda.c
Can anyone tell me what mistake I am making....
nvcc runs .c files through the normal C compiler. Rename your file to cuda.cu.