c++

Are there any static analysis tools that can help detect shared_ptr<> circular references?

Are there any static analysis tools that can help detect shared_ptr<> circular references? Even if such a tool couldn't detect complicated cases, it would still be useful for eliminating the simple cases. ...

error: boost.fusion::for_each() and struct derived from boost.tuple

Hi all! on compilation this code: struct any_type: boost::tuple<std::string, std::string, std::string> { ... }; struct functor { void operator()(const std::string& v) { std::cout << v << std::endl; } }; int main() { any_type type; boost::fusion::for_each(type, functor()); } get error: no type named 'category' in...

SD serial number

I am using the following code: int main() { DWORD dwBytesReturned = 0; BOOL bResult = DeviceIoControl(hVol, IOCTL_SFFDISK_DEVICE_COMMAND, pCmdBuf, nSizeOfCmd, pCmdBuf, nSizeOfCmd, &dwBytesReturned, NULL); But pCmdBuf->Data is always empty. I run the program with administrative privileges on a win7 x64. ...

Eclipse C/C++ Development Tools: Can't get standard error to appear in console

I'm working on a program in Eclipse, outputting debugging information to 'clog'. I can not get clog or cerr output to show up in the console. Not only would I like to read this information, but I'm getting program hangs waiting on inserts to clog to finish. I assume this is because no-one is pulling information from the stderr stream an...

Compilation error: `Class' does not name a type

Hi, I have a pretty simple class called simulator in simulator.h #include <iostream.h> #include <stdlib.h> Class Simulator { private: short int startFloor; short int destFloor; public: void setFloors(); void getFloors(short int &, short int &); }; Now when I compile it, I get this error: ...

Network Not Available Error when trying to map network drive

I'm calling WNetAddConnection2 during the login process for a 2008R2 box. The action happens right after userinit is run. I'm receiving a 1222 error or Network Not Available. Right after doing this I'm also connecting a couple printers using the AddPrinterConnection function. Both the printers and the network drives are on the same remot...

VS2008 not linking to all functions in a library

Our project is a VS2008 based project using Boost and Qt heavily. However, today we have a new linking problem that doesn't make any sense. What is happening is that during the link For program A, our static library Foobar is finding links to 5 of the 8 member functions. For program FoobarUnitTest, everything from Foobar links and ru...

Operating system in NOKIA phones

I want to know what operating system NOKIA smart-phones use? Which programming language is used to write it and is it possible to do kernel level programming for these systems? Can we use C codes to change the system software? Libraries are available or not? I have never coded for mobile phones. So if possible give me a link to the page...

string to float conversion?

I'm wondering what sort of algorithm could be used to take something like "4.72" into a float data type, equal to float x = 4.72; ...

Convert Hex String to Hex Value

I have a large hex string abcdef... and I want to convert it to 0xab 0xcd 0xef Are there any funtions that do that? Also could you tell me what I means when people ask are those inputs in ASCII or not? abcdef are represeted as a string. Not sure if that is ASCII or not. not sure what they mean. I am very new to programming so h...

Does map<key, data> in C++ STL support native data types like Structures?

I am trying to write something like this. My question is how do I map a key to a native data type like structure. I wrote this snipped but I couldn't compile it. Do you have any ideas on how to achieve this thing? #include <map> #include <iostream> typedef struct _list { int a,b; }list; map<int,list> test_map; int main(void) { cou...

C# interface C++ DLL?

How do I call functions from a C++ DLL? The C++ DLL contains functions like this: __declspec(dllexport) bool Setup () { return simulation.Setup (); } The C# program does this: [DllImport("mydll.dll")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool Setup(); The C# program crashes with the following message wh...

C/C++ Checking for NULL pointer

In a recent code review, a contributor is trying to enforce that all NULL checks on pointers be performed in the following manner: int * some_ptr; // ... if( some_ptr == NULL ) { // handle null-pointer error } else { // proceed } instead of int * some_ptr; // ... if( some_ptr ) { // proceed } else { //handle null-pointer err...

const correctness problem with copy constructor?

...

COM Interop: indexed property signature issues

I'm working on a project that's a .NET extension to a rather large classic ASP project, using a lot of C++ COM objects that have been around in our code base forever. Unfortunately, there's a lot of hack-ish code on the C++ side, and I fear that I'm not experienced enough to work out the problem I've encountered. In a nutshell, I can i...

teaching OO with numerical algorithm

I'm helping a professor for some lectures in OO and numerical algorithm in particular problem like to find the root of a function, minimization, interpolation, ... the problem is that he wants to teach at the same time OO with C++. I think that usual algorithms like these are implemented using procedural programming, at least you can use...

tbb::concurrent_hash_map throws SIGSEGV

I'm running a small program built using TBB on Windows with mingw32. It does a parallel_for. Inside the parallel_for my object makes changes to a concurrent_hash_map object. It starts running but later throws a SIGSEGV when I try to use an accessor. I don't know where the problem is. My object: class Foobar { public: Foobar(FoobarP...

How do I marshall (in ideally in SWIG) a C# string[] to a C++ string*?

I am new in C# programming and trying to call wrap functions that is in C++. In C++ I have a function of the following prototype string* swap(string* ptr1, string*ptr2){ //swap the array of string return ptr2; } How do I wrap this function into C# (ideally using SWIG, but not necessary)? ...

BOOST_PP_ITERATE() result in "no such file or directory"

Hi, I'm learning the boost preprocessor library (because i need to use it), and I wanted to try the file iteration mechanism. I've set up a minimal project with a.cpp and b.hpp. What I'm trying to do is including many time b.hpp via the boost pp : #include <boost/preprocessor/iteration/iterate.hpp> #define BOOST_PP_ITERATION_LIMITS (0...

Why does the F# Bitwise Operator pad with 1's for signed types?

I was looking at F# doc on bitwise ops: Bitwise right-shift operator. The result is the first operand with bits shifted right by the number of bits in the second operand. Bits shifted off the least significant position are not rotated into the most significant position. For unsigned types, the most significant bits are ...