c++

Getting the System tick count with basic C++?

I essentially want to reconstruct the getTickCount() windows function so I can use it in basic C++ without any non standard libraries or even the STL. (So it complies with the libraries supplied with the Android NDK) I have looked at clock() localtime time But I'm still unsure whether it is possible to replicate the get...

boost asio ssl stream socket compilation issue

Using boost 1.4.2 asio in a c++ app and getting linux compiler warnings i don't grok. still here? The app i'm working on needs a "socket" that might be an ssl socket or a regular tcp socket so we hide specifics behind a template "socket" class that takes either an ssl socket class or tcp socket class as template parameter - below is the...

gcc problem with explicit template instantiation?

It is my understanding that either a declaration or typedef of a specialization ought to cause a template class to be instantiated, but this does not appear to be happening with gcc. E.g. I have a template class, template class Foo {}; I write class Foo<double>; or typedef Foo<double> DoubleFoo; but after compilation th...

Calling member method on unmanaged C++ pointer from C# (I think)

I apologize in advance if this is a trivial question... I'm pretty C++ / unmanaged dumb. Here's a simplified analog to my setup: --In myUnmanagedObject.h in DLL: class myUnmanagedObject { public: virtual void myMethod(){} } --In MyControl.h in Assembly #1: #pragma make_public(myUnmanagedObject) [event_source(manag...

npruntime example plugin (c++) of NPAPI fails to run on mac OSX 10.5

Hi I have compiled Mozilla NPAPI plugin example npruntime on Mac OSX 10.5. It give me a libnprt.dylib I am bundling this dylib with proper plist. On loading the plugin, NP_GetMIMEDescription() is getting called (i am logging this), but its not going inside NP_GetEntryPoints(). How a part of code is getting loaded and a part not? Can...

Variable Argument list with no named argument?

Is it possible to have a function with variable arguments and no named argument? For example: SomeLogClass("Log Message Here %d").Log(5); SomeLogClass("Log Message Here %d").Error(5); ...

What is a truly empty std::vector in C++?

I've got a two vectors in class A that contain other class objects B and C. I know exactly how many elements these vectors are supposed to hold at maximum. In the initializer list of class A's constructor, I initialize these vectors to their max sizes (constants). If I understand this correctly, I now have a vector of objects of class ...

[MSVC++] Breakpoints on a variable changing value?

I'm chasing a bug where a member value of an object seems to magically change, without any methods being called which modify it. No doubt something obvious but proving hard to track down. I know I can put conditional break-points in methods based on the variable value, but is it in any way possible to actually put a breakpoint on a varia...

vector's clear vs setsize

I read on the net someplace that in a tight loop if you are clearing your vector repetitively, it might be better to use resize(0) as it might be faster. I am not sure about this. Anyone's got a definitive answer to this? ...

Using member variables inherited from a templated base class (C++)

I'm trying to use member variables of a templated base class in a derived class, as in this example: template <class dtype> struct A { int x; }; template <class dtype> struct B : public A<dtype> { void test() { int id1 = this->x; // always works int id2 = A<dtype>::x; // always works int id3 = B::...

c++ inline functions

i'm confused about how to do inline functions in C++.... lets say this function. how would it be turned to an inline function int maximum( int x, int y, int z ) { int max = x; if ( y > max ) max = y; if ( z > max ) max = z; return max; } ...

C++ OOP: Which functions to put into the class?

Assume I have a class a: class a { public: void load_data( ); private: void check_data( ); void work_data( ); void analyze_data( ); } Those functions all do something with the class or one of its members. However this function: bool validate_something( myType myData ) { if ( myData.blah > 0 && myData.blah < 100 ) ...

implement SIMD in C++

I'm working on a bit of code and I'm trying to optimize it as much as possible, basically get it running under a certain time limit. The following makes the call... static affinity_partitioner ap; parallel_for(blocked_range<size_t>(0, T), LoopBody(score), ap); ... and the following is what is executed. void operator()(const blocked...

C++ from SpeakHere in iPhone app

Hi guys, I've made a template app where I've grabbed the recording part of the SpeakHere example and removed the file handling part, but I'm struggeling to get the C++ part of the app working right. As soon as it enters the C++ class, it gets syntax errors. If I don't import the header files from C++ (and then of course don't use the co...

Reversing a for loop... want to print numbers in reverse

How would I change this loop to print prime number in reverse... starting from the biggest one first int main(){ bool prime; for( int i=3; i<=10000; i++){ prime = true; for(int n=2; n<=i-1; n++){ if( i%n == 0){ prime = false; } } if(prime){ cout...

Casting between variant and bstr_t causing inconsisten crash in Windows 2008

We have a C# application, calling a simple C++ wrapper class, that then calls an existing C++ DLL. The C++ code is all VC++ 6.0. We are getting inconsistent behaviour, but the crash, when it happens, always happens within the C++ wrapper DLL, and always in the same spot (have confirmed using painful logging statements). It never happe...

segfault on vector<struct>

Hello, I created a struct to hold some data and then declared a vector to hold that struct. But when I do a push_back I get damn segfault and I have no idea why! My struct is defines as: typedef struct Group { int codigo; string name; int deleted; int printers; int subpage; /*included this when it started seg...

Segmentation fault C++ in recursive function

Why do I get a segmentation fault in my recursive function. It happens every time i call it when a value greater than 4 as a parameter #include <iostream> #include <limits> using namespace std; int printSeries(int n){ if(n==1){ return 1; } else if( n==2){ return 2; } else if( n==3){ ...

C++ UTF-8 output with ICU

I'm struggling to get started with the C++ ICU library. I have tried to get the simplest example to work, but even that has failed. I would just like to output a UTF-8 string and then go from there. Here is what I have: #include <unicode/unistr.h> #include <unicode/ustream.h> #include <iostream> int main() { UnicodeString s = UNI...

error LNK2001: unresolved external symbol _D3DX10CreateTextureFromFileW@24

I am trying to call a direct X funciton but I get the following error error LNK2001: unresolved external symbol _D3DX10CreateTextureFromFileW@24 I understand that possibly there maybe a linker issue. But I am not sure where. I inluded both d3dx10.h and the d3d10.h. I also included the d3d10.lib file. Plus, the intellisense picks up on...