c++

Export function in c++ static library

My app links to a third party static library which without source code and I find that a function implemented in this library is exported in my exe using dumpbin.exe, just like a export function in a DLL. I have tried to modify the header file provided by the library, got rid of all the __declspec(dllexport) stuffs, and relink my app, b...

Help with Unit Testing

Hi, I am new for the Unit Testing Can some one tell me where this testing class is defined in the following code and how can i find it ? #ifndef UT_USERSESSIONMANAGER_ #def UT_USERSESSIONMANAGER_ #include<gmock/gmock-genral.h> //If define in this then how can i find it #include<"pre_include.hpp"> //I am sure not define in this #incl...

Tools to automatically generate Daos.

I'm not interested in Spring/JPA etc. I like straight up JDBC/ODBC. I was wondering what are the good (actually production ready) tools to enable taking a database schema and generating objects/daos that fetch/update them? I am intersted in Java and C++. I am interested in ramping up more on C++ in order to get away from all of this Spr...

Get method name from instrument function using MinGW/MSYS

Hi all, i've successfully get the GCC instrument functions functional with MSYS/MinGW. When i use instrument functions I only have the pointer as reference of the module, which has invoked the instrument function... Now I try to get more detailed information of the module. Using Linux OS i could use the dladdr function to grab the name...

Is it possible to pass an "unnamed" variable to a function?

Let's say there is the following function: void SetTheSize(const SIZE *size) { ... } Is there any way to call that function without specifying the SIZE variable? e.g., SetTheSize((const SIZE*)&{10, 10}); edit: I should had mentioned that the SIZE is a struct, without SIZE(int, int) constructor. ...

Throw (or correspondingly) on NULL function argument versus letting it all blow up?

In previous large-scale applications requiring high robustness and long up-times, I've always been for validating a pointer function argument when it was documented as "must never be NULL". I'd then throw an std::invalid_argument exception, or similar, if the argument actually was NULL in C++ and return an error code in C. However, I'm ...

Function that returns iterator from a map

I have a class with a map<K,V> variable which gets its value in the c'tor like so: class Foo { map<K,V> m; Foo (map<K,V>& newM) : m(newM) {} map<K,V>::iterator bar () { ... } } the function bar iterates through the map m, and return some an iterator to some element. I'm calling the function like this: std::map<K,V> map; /...

What is an iterator's default value?

For any STL container that I'm using, if I declare an iterator (of this particular container type) using the iterator's default constructor, what will the iterator be initialised to? For example, I have: std::list<void*> address_list; std::list<void*>::iterator iter; What will iter be initialised to? ...

destructor is never called

sorry for my inattension, in short the ~CSArray() is work, but interface and implementation of the class there was in different files, so mistake is here ...

Overloading operator<< to accept a template function

I'm trying to be able to write an extensible grammar using functions, but can't seem to find the right syntax for accepting a template function. I'm using Visual C++ 2008. It will accept a variable of the same type as the template function, or a similar non-template function, but not the template function itself. Error 1 error C2...

How to implement "record macro" like that in Microsoft Excel?

How to implement "record macro" like that in Microsoft Excel? PS: any language/platform. I just want an idea of how to do that. as far as i know, i can embed a script interpreter(maybe javascript) and make c++ object visible to scripts, just DOM in web browser. My question is that how to record user actions and then generated javascript ...

WinAPI - Problem to append text to an editbox

Hi, I created a simple window with a multiline Edit Control: Edit = CreateWindowEx(WS_EX_CLIENTEDGE, TEXT("EDIT"), NULL, WS_CHILD | WS_VISIBLE | ES_MULTILINE, 20, 200, 200, 200, hWnd, (HMENU)EDIT, GetModuleHandle(NULL), NULL); If I set text using a WM_SETTEXT message, I don't...

Can I map lists in QT?

This is already fairly concise, but it would be awesome if I could map the list a la Ruby. Say I have a QStringList, myStringList, which contains things like "12.3", "-213.0", "9.24". I want to simply map the whole thing using toDouble without having to iterate. Does QT have a method for this? // i.e. I would love a one-liner for the fo...

Textarea for Cario:OpenGL

Is there an off the shelf textarea class that uses Cario (targetting OpenGL) as the renderer? By textarea I mean a multiline textfield with wordwrap and width and height constraints. The code that needs to use this class is written in C++. ...

How to retrieve the HD vendor/serial using Windows API

I'm talking about the physical disk drive, not volume/partition/logical drive. So that usually-suggested GetVolumeInformation function is not applicable in my case. To be exact: I'm working directly with the disk which has not been partitioned yet. I open a handle to it via CreateFile function: hDisk = CreateFile( _T("\\\\.\\PHYSIC...

Where to put BOOST_CLASS_EXPORT for boost::serialization?

I'm trying to serialize a pointer to a polymorphic class Shape. So I need to use the BOOST_CLASS_EXPORT macro to define a GUID for each subclass. The problem: where to put it? Let me show a minimal test case first: shapes.hpp #include <boost/serialization/access.hpp> #include <boost/serialization/base_object.hpp> #include <boost/seria...

C++ - basic container question

Hello! How should the following cases be handled: I have some geometrical storage, which is a template from vertex type. template <typename T> struct Geometry { std::vector<T>& GetVertices() { ... } const void* RawVertices() const { ... } } This works fine, unless I want to store different types of geometries (for instance, Geome...

SEGMENTATION FAULT in vector<string> iterator function used to draw text to my self-coded GUI.

Greetings all, ERROR: Program received signal 'SIGSEGV', Segmentation fault. I am having some issues with the following code creating the above fault in Code::Blocks. It is for a chatbox I am using for a network chat program where the vector is filled with the strings of text for each line of the chat log. I don't see why its throwing...

c, c++ most basic double quotes

char* a="HELLO WORLD"; IF ADDRESS of 'H' is 0x01 then the printf with %s prints to D but if the same code is written with manual printing routine while(*a!=NULL) {printf("%c",n[a]);n++;} this prints a few more characters.. but printf("%s",a); prints it perfectly. while(*a++) printf("%c", *(a-1)); or for(;*a++;)printf("%c", *(...

Memory corruption when using boost::shared_ptr in a multithreaded environment

* glibc detected malloc(): memory corruption (fast): ** This is the error I get when, in a multithreaded environment, I execute this portion of code: /// Some declarations typedef boost::shared_ptr<Object> ObjectPtr; ObjectPtr getObject() { return ObjectPtr(new Object); } /// What is actually executed in a thread void executeWor...