question_id int64 25 74.7M | answer_id int64 332 74.7M | title stringlengths 20 150 | question stringlengths 23 4.1k | answer stringlengths 20 4.1k |
|---|---|---|---|---|
1,209,406 | 1,209,473 | Interprocess Communication between C++ app and Java App in Windows OS environment | We have a C++ application on Windows that starts a java process. These two apps need to communicate with each other (via snippets of xml).
What interprocess communication method would you choose, and why?
Methods on the table for us are: a shared file(s), pipes and sockets (although I think this has some security conce... | I'm not sure why you think socket-based communication would have security concerns (use SSL). It is often a very good approach as it is language agnostic, assuming that you have a well-defined communication protocol. Have a look at Google's protocol buffers, for example - they generate the required Java classes and str... |
1,209,497 | 1,209,516 | How to configure Visual Studio for native C++ (unmanaged) development? | I am completely new to C++ development and am trying to learn it in Visual Studio. How can I be sure that I am learning only C++ and not the managed extensions? What configuration settings do I need to change? What project types should I stick to? Any other advice?
Side issue:
I have tried turning off Language Extensio... | The fact that you have /clr switch in there means you're using a .Net project type - you need to choose a "Win32" project type to get a pure C++ project.
Avoid anything calling itself "managed" or "CLR".
|
1,209,528 | 1,209,839 | Converting simple C++ code to C# automatically | I have a file in C++ containing constant definitions, I want to use the same definitions in a C# project. Since both projects are part of a bigger project, I want if there is a change (addition/deletion) in the C++ file it should get reflected in corresponding C# file too. I want to keep the 2 files in sync. I was wond... | You probably wont find a script... You should have your own script to do this. Otherwise MACROs are the best fit...
If you have a script then you can create a rule in your makefile that will automatically run this script whenever you build your project.
|
1,209,748 | 1,210,156 | How do I call C++ functions from a Lua script? | I'm using Visual Studio 2005.
------------------------[ luapassing.cpp ]--------------------
#include "lua.h"
static int myCfunc (Lua_State *L){
double trouble = lua_tonumber(L,1);
lua_pushnumber(L,16.0 -trouble);
return 1;
}
int luaopen_luapassing (Lua_State *L){
static const lua_reg Map [] = {{"dothis",my... | I see several issues. I'll describe them, and provide a code fragment that should work as I believe you intended this sample to work.
Your first problem is that the C++ compiler mangled the name of the only function exported from your DLL whose name matters to Lua: luaopen_luapassing(). The stock binary distribution fo... |
1,209,885 | 1,209,920 | Visual Studio: How to Build a Static Library for use in Another Project (Avoiding STL Linking Errors) | I'm new to Visual Studio and Windows as a development platform, and I'm having troubles linking a static library from one 'Project' into an executable in another. The library builds without error, but linking bails after finding several STL template instantiations defined in the library.
For the purpose of this questio... | You have mismatching runtime libraries specified.
It is set to /MTd for project A and /MDd for project B.
/MTd - Multithreaded Debug
/MDd - Multithreaded Debug DLL
|
1,209,893 | 1,220,022 | CStatic Custom Control | I am trying to create a custom CStatic control in vc++ and have a few problems.
I originally was just using a CStatic control with the SS_BLACKRECT style. This was good for the situation until I needed to display an image over the control on demand.
I figured out all the logistics behind actually drawing the image onto... | Try calling Default() in your OnPaint() handler.
Then, depending on whether you're drawing your image, you can then draw over the top of the standard CStatic control.
|
1,210,013 | 1,210,049 | Why isn't stl compare function a member? | Just idly curious why the compare function for stl::sort can't be a static member?
I have a small little helper class foo that is declared and defined in a header, but now I have to create a foo.cpp file for the implementation of cmp() so it isn't multiply defined.
I also have to think of a suitably decorated name ... | I am not sure what you are complaining about:
std::sort(begin,end) // use operator<
std::sort(begin,end,order) // Where order is a functor
So order can be:
A function
A static member function
Or an object that behaves like a function.
The following works for me:
class X
{
public: static bool diff(X const... |
1,210,072 | 1,210,270 | How to select an unlike number in an array in C++? | I'm using C++ to write a ROOT script for some task. At some point I have an array of doubles in which many are quite similar and one or two are different. I want to average all the number except those sore thumbs. How should I approach it? For an example, lets consider:
x = [2.3, 2.4, 2.11, 10.5, 1.9, 2.2, 11.2, 2.1]
... | Given that you are using ROOT you might consider looking at the TSpectrum classes which have support for extracting backgrounds from under an unspecified number of peaks...
I have never used them with so much baseline noise, but they ought to be robust.
BTW: what is the source of this data. The peak looks like a partic... |
1,210,115 | 1,210,145 | How to call c++ functionality from java | I have a Java program that is mostly GUI and it shows data that is written to an xml file from a c++ command line tool. Now I want to add a button to the java program to refresh the data. This means that my program has to call the c++ functionality.
Is the best way to just call the program from java through a system c... | Assuming no better communication method is available (SOAP, ICE, Sockets, etc), I'd call the executable using Runtime.exec(). JNI can be used to interface directly, but I wouldn't recommended it. No you can't put an executable in the jar. Well you can, but you can't run it, since the shell doesn't know how to run it.
|
1,210,149 | 1,210,154 | serving up a png file via ifstream | This seems like a really simple task, so bear with me. I'm trying to extend a server which serves up files and webpages. Currently the server gets an HTTP request, parses it, and calls a function called sendFile:
void sendFile(ostream& ostr, std::string filename) {
std::ifstream ifs(filename.c_str(), std::ios_bas... | You really should be setting the length and the mime type in the http headers.
|
1,210,282 | 1,210,293 | C++ linker problems with static method | I'm writing a Vector3D class that calls a static method on a VectorMath class to perform a calculation. When I compile, I get this:
bash-3.1$ g++ VectorMath.cpp Vector3D.cpp
/tmp/cc5cAPia.o: In function `main':
Vector3D.cpp:(.text+0x4f7): undefined reference to 'VectorMath::norm(Vector3D*)'
collect2: ld returned 1 exi... | You're missing this:
//VectorMath.cpp
#include "VectorMath.h"
|
V - here
Vector3D* VectorMath::norm(Vector3D* vector)
{
...
}
The norm function is part of VectorMath::. Without that, you just have a free function.
This is more about your design, but why are you using pointers to everyth... |
1,210,306 | 1,320,197 | Format of parameter to display call graph for templated method with gprof? | What is the command line format to display function call graph for a method in templated class with gprof?
For simple C method you would specify it like:
gprof -f foo myprogram > gprof.output
How do you specify method parse from the following:
template <typename T> class A
{
public:
template <typename X> b... | I was after the actual format to be used on command line. I can see the compiled symbols by looking at the generated files but I'm not sure what format to use on command line. Thanks anyway for all answers.
|
1,210,362 | 1,210,379 | Which C++ material should I work on next? | I've been doing C++ for 3-4 months in a local college and I'm doing extra reading / learning using Accelerated C++ and so far, I've "finished" it. Now, I'm wondering which book to get next that'll help me code better in C++.
I've looked around and found this: The Definitive C++ Book Guide and List
I'm sorry if this qu... | If you haven't yet read Stroustrup's books, they are definitely a good read. There's nothing quite like reading about the language from the person who designed it.
Whenever I learn a new language, I always try to find the canonical reference material written by the language designer or somebody very close to them.
|
1,210,533 | 1,210,556 | interposers on Windows | Is it possible to substitute system functions, as is possible on Linux and Solaris using the LD_PRELOAD
For example by setting the environment variable:
LD_PRELOAD=/path/to/mymalloc.so
I would have my replacement malloc functions instead of in the C runtime already installed in the system libraries. All other function... | Microsoft Research has a library called Detours which allows you to intercept Win32 API calls.
Detours is a library for instrumenting arbitrary Win32 functions on x86, x64, and IA64 machines. Detours intercepts Win32 functions by re-writing the in-memory code for target functions. The Detours package also contains uti... |
1,210,623 | 1,210,634 | best way to write a linux daemon | For work i need to write a tcp daemon to respond to our client software and was wondering if any one had any tips on the best way to go about this.
Should i fork for every new connection as normally i would use threads?
| It depends on your application. Threads and forking can both be perfectly valid approaches, as well as the third option of a single-threaded event-driven model. If you can explain a bit more about exactly what you're writing, it would help when giving advice.
For what it's worth, here are a few general guidelines:
If ... |
1,210,988 | 1,210,995 | For C++ developers, is it worth to switch from VS2005 to VS2008? | We're mostly doing C++ developing in Visual Studio 2005, and some C# coding. We're considering upgrading to Visual Studio 2008, but we're wondering if it will be worth the trouble. From what I've seen, and that is not much, VS2008 doesn't have any big advantages over VS2005. So is it worth switching to VS2008 from VS20... | No, not really. There were only minor improvements to the C++ IDE, and the major improvements coming from the C++ team at MSFT are in Visual Studio 2010 (including an intellisense overhaul). It would not be beneficial to C++ developers in anyway really, you're not missing out.
|
1,211,092 | 1,211,214 | Implementing Monitor with signaling using mutex and condition variable in C++ | Did any body implemented a Monitor with signaling (wake up waiting threads) using a mutex and condition variables in C++.
I dont know how to start. Any sample code or online article will be great.
Are there any open source libraries who have implemented these?
I need for windows and linux. But to start with windows(win... | This Qt Quarterly article explains how to do this using Qt's QMutex and QWaitCondition. But you should be able to reimplement it with whatever mutex class you want to use..
See also the more advanced example in here..
|
1,211,144 | 1,211,436 | What features to implement in a version control system? | I will be implementing a version control system in C++ for my final year project.
I would like to know:
What are the features a version control system should must support.
What features do you consider are missing in existing implementations (so that my version control system does more than just reinventing the wheel)... |
What are the features a version control system should must support.
Core features: Create Project, Check in, Check out, Branch, Get Latest/Previous, View History, Compare, Rollback
What features do you consider are missing in existing implementations (so that my version control system does more than just reinventi... |
1,211,190 | 1,386,558 | How to setup sound intensity on windows mobile? | I playing a sound file with a custom player, when the mobile goes in suspend mode (because the user pushed the red button) I would like to resume sound intensity when the mobile resume. How can I do ?
| You can set the volume by opening the waveOut device and setting the volume. This will affect all sound playback:
waveOutOpen
waveOutSetVolume
|
1,211,399 | 1,211,402 | In C++, what is a "namespace alias"? | What is a "namespace alias" in C++? How is it used?
| A namespace alias is a convenient way of referring to a long namespace name by a different, shorter name.
As an example, say you wanted to use the numeric vectors from Boost's uBLAS without a using namespace directive. Stating the full namespace every time is cumbersome:
boost::numeric::ublas::vector<double> v;
Instea... |
1,211,841 | 7,273,530 | How can I make Visual Studio's build be very verbose? | I need to get a hold of every flag, every switch used in the build process by the Visual Studio binaries. I tried to obtain a verbose output by using vcbuild, but I wasn't able.
What do I have to do to see everything performed by Visual Studio for me? It's not necessary to obtain the output in the build window. Anywhe... |
Open the project properties dialog, then choose
Configuration Properties → C/C++ → General
Change the setting for Suppress Startup Banner to No
The cl command line(s) will be shown in the output window.
|
1,211,982 | 1,212,950 | Can someone explain how the signedness of char is platform specific? | I recently read that the differences between
char
unsigned char
and
signed char
is platform specific.
I can't quite get my head round this? does it mean the the bit sequence can vary from one platform to the next ie platform1 the sign is the first bit, platform2 the sign could be at the end? how would you code agains... | Let's assume that your platform has eight-bit bytes, and suppose we have the bit pattern 10101010. To a signed char, that value is −86. For unsigned char, though, that same bit pattern represents 170. We haven't moved any bits around; it's the same bits, interpreted two different ways.
Now for char. The standard doesn'... |
1,212,391 | 1,223,284 | Microsoft Visual Studio: Loading resources in Qt application (without plug-in) | We don't have a Qt plug-in installed for MSVS, and it makes me wonder how/whether it is possible to load resources (images, etc) to the application.
| Yes, you can load ressources.
Unfortunately, the qrc Editor which create qrc files is part of the Qt Addin for VS...
But you can create this xml file by hands, for the format see here
Once the qrc file created, you have at least two possibilities :
A) Use qmake
Add a reference to your qrc file in your pro file :
RES... |
1,212,525 | 1,212,638 | How do I change the background color of a conditional macro in eclipse? | How do I change the background color of a conditional macro in eclipse? I am using the C/C++ version of Eclipse so I would assume it would be associated with a mysterious preprocessor background color setting.
| Preferences -> C/C++ -> Editor -> Inactive Code Highlight
Duh! ;-)
|
1,212,713 | 1,212,809 | Marshaling from C# to C++ | I gotta pass an InParameter from my C# application to an exported function from a VC++ DLL. The function accepts 2 parameters :
int func_name (FILE* fp, BYTE& by);
fp is In and by is Out parameter.
I was thinking of marshaling using IntPtr for the FILE* and using byte for BYTE. Is it correct? If I write the following ... | If native function expects reference, you can marshal it using it ref/out. So in your situation, you could use:
out byte by. I've checked it, and it works for me.
Edit again: It just came to my mind, that advices I gave you won't work, as FILE is a struct, that you won't be able to marshall from c# that easily. So sc... |
1,212,859 | 1,213,909 | Real time dynamic shadows to complement deferred shading? | I currently have a deferred rendering system setup and can render point lights and directional lights. My question is what are my options for different forms of shadowing which can make shadows based on point lights and directional lights which can maybe make use of a deferred shading setup?
| There's not really anything special about deferred rendering that requires unique shadowing techniques. Most of the standard approaches to producing shadows work just fine with deferred rendering schemes.
Shadow mapping is the most common shadowing algorithm in use today in real time applications like games. Stencil sh... |
1,212,874 | 1,215,348 | mmap to overlay VME bus into user space memory over a PCI? | I'm trying to map a VME address space through a PCI bus into user space so I can perform regular read/writes on the memory.
I have done this with another PCI device like this :-
unsigned long *mapArea(unsigned int barAddr, unsigned int mapSize, int *fd)
{
unsigned long *mem;
*fd = open("/dev/mem", O_RDWR);
... | Where does /dev/vme_m0 come from and what does it represent? It is hard to tell what opening and accessing it will do without knowing more.
You need to look at the bridge chip manual to figure out how a read/write to Region 1 will translate to a read/write on the VME bus. The bridge chip should have a set of register... |
1,212,978 | 1,213,058 | In C++, if throw is an expression, what is its type? | I picked this up in one of my brief forays to reddit:
http://www.smallshire.org.uk/sufficientlysmall/2009/07/31/in-c-throw-is-an-expression/
Basically, the author points out that in C++:
throw "error"
is an expression. This is actually fairly clearly spelt out in the C++ Standard, both in the main text and the grammar... | According to the standard, 5.16 paragraph 2 first point, "The second or the third operand (but not both) is a throw-expression (15.1); the result is of the type of the other and is an rvalue." Therefore, the conditional operator doesn't care what type a throw-expression is, but will just use the other type.
In fact, 1... |
1,213,229 | 1,215,062 | How to acquire an event only at defined times? | I have a QWidget which handles the mouseevent, i.e. it stores the mouseposition in a list when the left mouse button is pressed.
The problem is, I cannot tell the widget to take only one point every x ms.
What would be the usual way to get these samples?
Edit: since the mouseevent is not called very often, is it possib... | It sounds like you don't want asynchronous event handling at all, you just want to get the location of the cursor at fixed intervals.
Set up a timer to fire every x milliseconds. Connect it to a slot which gets the value of QCursor::pos(). Use QWidget::mapFromGlobal() if you need the cursor position in coordinates lo... |
1,213,265 | 1,213,285 | How is heap and stack memories mananged, implemented, allocated |
Possible Duplicates:
How is heap and stack memories mananged, implemented, allocated?
Stack,Static and Heap in C++
In C/C++ we can store variables, functions, member functions, instances of a class either on a stack or a heap.
How is each implemented? How is it managed (high level)? Does gcc preallocates a chunk of... | I think to your question one can easily write at least some chapters for the book on Operating Systems. I suggest you to read Tanenbaum: Modern Operating Systems.
Main difference of heap and stack, that one is per process item, the other per thread item. Initially when program is started it gets some minimal heap and s... |
1,213,334 | 1,213,820 | Boost.Intrusive and unordered_map | I am looking to use an intrusive unordered_map. For some reason there is only an unordered_set in the library. There is also an intrusive hashtable but I'm not sure it has the same functunality, also it doesn't have the same interface.
Am I wrong and I missed the unordered_map link?
If I am not is there a tutorial that... | It's an interesting question. Boost.Intrusive doesn't seem to provide any map interface, ordered or unordered. It has a lot of implementation types that will work fine as maps both ordered (red-black trees, AVL trees, splay trees) and unordered (hashtables). But no maps and I couldn't tell you why.
You have two choic... |
1,213,366 | 1,213,537 | Can template polymorphism be used in place of OO polymorphism? | I am trying to get my head around applying template programming (and at some future point, template metaprogramming) to real-world scenarios. One problem I am finding is that C++ Templates and Polymorphism don't always play together the way I want.
My question is if the way I'm trying to apply template programming is i... | Templates provide static polymorphism: you specify a template parameter at compile time implementing the strategy. They don't provide dynamic polymorphism, where you supply an object at runtime with virtual member functions that implement the strategy.
Your example template code will create three different classes, eac... |
1,213,418 | 1,213,440 | Why won't C++ allow non-const to const conversion in copy ctor? | I have two getter members:
Node* prev() { return prev_; }
int value() { return value_ }
Please note the lack of const identifiers (I forgot them, but now I want to know why this won't work). I am trying to get this to compile:
Node(Node const& other) : prev_(other.prev()), value_(other.value()) { }
The compiler reje... | You're not trying to do a non-const to const conversion. You're attempting to call two methods which are not const an a const reference (calls to prev and value). This type of operation is strictly forbidden by const semantics.
What you could do instead is use the fields prev_ and value_ directly. Because it's a m... |
1,213,607 | 1,213,624 | How to manage large buffer in C++? | If I need a large buffer in my program written in C++, which one is better?
Allocate the buffer in heap, and keep a reference to that buffer in the class
that use it.
Allocate a static buffer, and make it global.
| How about: 3. Use a vector.
[Edited to add: or boost::array is a good option if you're happy with the dependency]
|
1,213,768 | 1,213,818 | Visual c++ redistributable redistribution | I'm coming from a Linux background, but I'd like to provide a version of my software on Windows. For users to run my program, they will need the Visual C++ redistributable. I would like to provide it for them as part of the package.
My worry is that there, in the future, will be an SP2 of the Visual Studio 2008 Redis... | With VS 2008 the runtimes are manifested and will install side-by-side. So if your application is linked to SP1's runtime, it will run only with the SP1 runtime (unless a manifest explicitly indicates that the Sp1 version should be overridden).
So you're protected from that type of DLL hell, in exchange for another (t... |
1,214,099 | 1,214,262 | Profile single function in gprof | Is it possible to use gprof to line-profile a single function in C++?
Something like:
gprof -l -F function_name ...
, which does not seem to work.
| That can be done easily with valgrind. It is a wonderful tool if you have the chance to use it in your development environment. It even have and graphical interface kcachegrind.
|
1,214,151 | 1,214,404 | Can we take advantage of the type system to make programs more secure? | This question is inspired from Joel's "Making Wrong Code Look Wrong"
http://www.joelonsoftware.com/articles/Wrong.html
Sometimes you can use types to enforce semantics on objects beyond their interfaces. For example, the Java interface Serializable does not actually define methods, but the fact that an object implement... | The type system already enforces a huge number of such safety features. That is essentially what it's for.
For a very simple example, it prevents you from treating a float as an int. That's one aspect of safety -- it guarantees that the type you're working on are going to behave as expected. It guarantees that only str... |
1,214,796 | 1,214,856 | Dev-C++ include file paths FLTK(Fast Light Toolkit) | When I compile and run programs in Bloodshed I save everything into a a folder labeled C++ in my username folder. When I downloaded FLTK, extracted it to the C++ folder, then tried to run a program using header files from FLTK, it was unable to find the files. My guess is that when the compiler looks for the header fil... | Most people here probably don't use DevC++, having been warned off it by people like me. DevC++ has lots of problems and is no longer being developed. You should consider
switching to Code::Blocks, which is better in just about every way.
|
1,214,805 | 1,215,593 | windows: load a filter driver while windows is running | Is it possible to install a keyboard filter driver(like ctrl2cap) while windows is running and not having to reboot? I tried it once with a driver loader but I got a BSOD. If it is possible what was I doing wrong? What can I do next time to not get a BSOD? Also, if it is possible, could I do it with c++? Thanks for the... | The simple answer is you cannot dynamically load a filter driver. You need to specify a load order when you install the filter driver. I assume the filter driver is layered on top of kbdclass. As kbdclass is already loaded this is not possible.
|
1,214,876 | 1,214,910 | guidelines on usage of size_t and offset_t? | This is probably a C++ 101 question: I'm curious what the guidelines are for using size_t and offset_t, e.g. what situations they are intended for, what situations they are not intended for, etc. I haven't done a lot of portable programming, so I have typically just used something like int or unsigned int for array siz... | You are probably referring to off_t, not offset_t. off_t is a POSIX type, not a C type, and it is used to denote file offsets (allowing 64-bit file offsets even on 32-bit systems). C99 has superceded that with fpos_t.
size_t is meant to count bytes or array elements. It matches the address space.
|
1,215,055 | 1,215,150 | Why is the use of typedef in this template necessary? | When I compile this code in Visual Studio 2005:
template <class T>
class CFooVector : public std::vector<CFoo<T>>
{
public:
void SetToFirst( typename std::vector<CFoo<T>>::iterator & iter );
};
template <class T>
void CFooVector<T>::SetToFirst( typename std::vector<CFoo<T>>::iterator & iter )
{
... | This compiles as well and reveals the source of VC++ confusion -- allocator type. Apparently outside of the class VS selects different default. Or maybe it can't recognize them to be the same.
Compiles on VS2008 (as is) and VS2003 (with space between >>)
template <class T>
class CFoo
{
public:
T m_t;
};
template <... |
1,215,186 | 1,215,204 | Do the Qt database modules support remote databases through a network connection? | I'm profiling some APIs to see which one is suitable for this project.
I want my Qt app to connect to a database over an internet connection. Can Qt do this with the client application alone or do I need to write a server app to sit on the database server and transact the queries?
| You can perfectly well connect to databases over TCP/IP as long as the database engine supports that (most do!). See the example in the docs, it has a db.setHostName("acidalia"); to connect to a PostgreSQL database on that host...
|
1,215,402 | 1,215,441 | Difference between event object and condition variable | What is the difference between event objects and condition variables?
I am asking in context of WIN32 API.
| Event objects are kernel-level objects. They can be shared across process boundaries, and are supported on all Windows OS versions. They can be used as their own standalone locks to shared resources, if desired. Since they are kernel objects, the OS has limitations on the number of available events that can be alloc... |
1,215,665 | 1,216,098 | C version of C++ std::map | Is there a C library version of the C++ std::map in a standard library?
| std::map is not a hash table. Therefore, my suggestion: Red-Black Tree C Code
The following C files implement balanced binary trees using the red-black paradigm. I have written these functions in a very general manner so that the key can be anything at all. Each node of the balanced binary tree must contain a key and ... |
1,215,688 | 1,216,329 | Read Something After a Word in C++ | I'm building a simple interpreter of a language that i'm developing, but how i can do a cout of something that is after a word and in rounded by "", like this:
#include <iostream>
#include <fstream>
#include <string>
#include <cstdlib>
using namespace std;
int main( int argc, char* argv[] )
{
if(argc != 2)
{
co... | I'm assuming what you want is to identify quoted strings in the file, and print them without the quotes. If so, the below snippet should do the trick.
This goes in your while(!file.eof()) loop:
string linha;
while(!file.eof())
{
getline(file, linha);
string::size_type idx = linha.find("\""); //find the first qu... |
1,215,777 | 1,215,781 | Writing a graphical Z80 emulator in C or C++ | I want to take an interest in writing my own simple emulator for the Z80 processor. I have no experience with this type of programming. I am mostly fine with using C-based languages as they are the ones I know best.
What do I need to accomplish this and what are some good tutorials/references that could aid me in this... | Perhaps start by looking at these:
A good tutorial can be found here: Independent Z80 Assembly Guide
Z80 DOCUMENTATION
The Undocumented Z80 Documented v0.91 (pdf)
The Complete Z80 Instruction Reference
Z80 Microprocessor Instruction Set Summary
|
1,215,838 | 1,215,844 | C++: Default values for template arguments other than the last ones? | I have my templated container class that looks like this:
template<
class KeyType,
class ValueType,
class KeyCompareFunctor = AnObnoxiouslyLongSequenceOfCharacters<KeyType>,
class ValueCompareFunctor = AnObnoxiouslyLongSequenceOfCharacters<ValueType>
>
class MyClass
{
[...]
}
Which mea... | In general, both in templates and functions or methods, C++ lets you use default for (and thereby omit) only trailing parameters -- no way out.
I recommend a template or macro to shorten AnObnoxiouslyLongSequenceOfCharacters<MyKeyType> to Foo<MyKeyType> -- not perfect, but better than nothing.
|
1,216,194 | 1,216,250 | How to Filter calls in NOKIA N73 | I am am new to mobile app development. But i would like to know if this is possible to intercept incoming calls on my N73 using code like Java or C++?
My second question is if this is possible then can we prevent the phone from ringing with a specified phone number from a black listed contact???
I've seen a lot of apps... | In C++ you can use CTelephony from etel3rdparty. Use NotifyChange() to subscribe to EVoiceLineStatusChange events. On an EStatusRinging event you can call GetCallInfo() to retrieve the remote party information, including phone number, and then decide whether to reject the call or let it keep ringing.
As far as I know, ... |
1,216,360 | 1,216,373 | How to use the C++ Sockets Library | I'd like to do some network socket programming in C++ and have found the C++ Sockets library.
First, is this a good way to go in C++? Normally in C, I'd use some of the stuff beej describes in his tutorial.
Second, how do I compile the examples given on the site? I can't figure it out from their installation/configura... | That's not "the" C++ sockets library, it's "a" C++ sockets library. Boost.asio has another (http://www.boost.org/doc/libs/1_39_0/doc/html/boost_asio.html).
(Community Wiki since I can't actually help you with your question - I've never compiled the code you ask about, so I don't know at what point you might have trippe... |
1,216,588 | 1,217,246 | Invoking methods in QThread's context | In my application there's the main thread and a worker thread (QThread).
From the main thread I'd like to invoke a method of my worker thread and have it run in the thread's context.
I've tried using QMetaObject::invokeMethod and give it the QueuedConnection option but it's not working.
I've also tried emitting signals... | The problem was that the receiver (the QThread) 'lives' in the main thread and thus the main thread's event loop is the one that executes the slot.
from Qt's docs:
With queued connections, the slot is invoked when control returns to the event loop of the thread to which the object belongs. The slot is executed in the ... |
1,216,750 | 1,216,758 | How can I simulate interfaces in C++? | Since C++ lacks the interface feature of Java and C#, what is the preferred way to simulate interfaces in C++ classes? My guess would be multiple inheritance of abstract classes.
What are the implications in terms of memory overhead/performance?
Are there any naming conventions for such simulated interfaces, such as S... | Since C++ has multiple inheritance unlike C# and Java, yes you can make a series of abstract classes.
As for convention, it is up to you; however, I like to precede the class names with an I.
class IStringNotifier
{
public:
virtual void sendMessage(std::string &strMessage) = 0;
virtual ~IStringNotifier() { }
};
Th... |
1,217,056 | 1,217,085 | C++ main() in a large OOP project | This may be a short & simple question, but I've never found a satisfying answer to it:
What code does the main() function usually consist of in a large C++ project? Would it be an incorrect assumption to think that it is usually just initializing a (wrapping) class object and calling a function inside of it to set thin... | In my code, it's basically a constructor call, possibly a method call, and some exception handling. This is the main for own of my projects (headers and comments omitted, and formatting messed up by SO, as usual):
int main( int argc, char * argv[] ) {
int result = 0;
try {
CLIHandler ch( argc, argv );
... |
1,217,173 | 1,217,177 | How to have a char pointer as an out parameter for C++ function | I'm a newbie to C++. I'm trying to have a char pointer as an out parameter for a function. But the changes made in the function are not reflected in the main function. What am I doing wrong?
void SetName( char *pszStr )
{
char* pTemp = new char[10];
strcpy(pTemp,"Mark");
pszStr = pTemp;
}
int _tmain(int ar... | Your pointer is being copied onto the stack, and you're assigning the stack pointer. You need to pass a pointer-to-pointer if you want to change the pointer:
void SetName( char **pszStr )
{
char* pTemp = new char[10];
strcpy(pTemp,"Mark");
*pszStr = pTemp; // assign the address of the pointer to this char p... |
1,217,196 | 1,217,202 | c++ memory allocation question | im trying to create an array:
int HR[32487834];
doesn't this only take up about 128 - 130 megabytes of memory?
im using MS c++ visual studios 2005 SP1 and it crashes and tells me stack overflow.
| While your computer may have gigabytes of memory, the stack does not (by default, I think it is ~1 MB on windows, but you can make it larger).
Try allocating it on the heap with new [].
|
1,217,236 | 1,217,293 | C++ Fast way to convert between image formats | Ive got some in memory images in various simple formats, which I need to quickly convert to another format. In cases where the target format contains an alpha channel but the source does not, alpha should be taken as its full value (eg 0xFF for an 8bit target alpha channel).
I need to be able to deal with various forma... | You might want boost::gil.
|
1,217,302 | 1,217,320 | Which is more secure OFB or CFB? | I'm working a small project, using AES encryption and wanted to use it in streaming mode, which is considered a more "suitable" mode for socket usage? OFB or CFB?
I've been reading about it and can't really decide, so any ideas are highly appreciated.
I'll be using OpenSSL/C++.
| Both OFB and CFB are solid if unexciting cipher modes (compared with, say, 'Infinite Garble Extension', IGE, which at least sounds more exciting) - either will serve you well. Choose one and stick with it. And, if Bruce Schneier's blog is correct, use AES-128 (rather than either AES-192 or AES-256).
|
1,217,471 | 1,217,502 | Using libxml2 in Visual Studio 2008 and Windows XP | I have a weird problem when running an application that uses GNOME's libxml2 under Visual Studio 2008 (VS2008-SP1) and Windows XP.
I have two C++ projects:
Project A (a library)
Project B (an application that depends on Project A)
Both under one VS solution.
Project A is statically compiled with libxml2.lib. I've ad... | Considering that libxml2 is Gnome based project, I'm guessing it doesn't come by default on any Windows installation.
I'm betting the reason it works on Vista is that you have a different program installed on Vista which happens to include that library. Hence it works there by accident and not design.
I agree wit... |
1,217,575 | 1,217,669 | Undefined Reference to class function issue | I've scoured the internet and my own intellect to answer this basic question, however, much to my own dismay I've been unable to find a solution. I'm normally pretty good about multiple header files however I have hit a wall. The problem is a function that I've declared in a header and defined in its proper namespace i... | If you compile using the IDE, look for some button like "add file to project" or something like this, to add the Matrix4x3.cpp file to your project, so that when you build it, the IDE will put the translated result to the linker and all functions are resolved.
Currently, it looks like you don't tell the IDE about that... |
1,217,603 | 1,218,503 | I can't understand the usage of the normal class libraries of the Java | I'm a beginner at Java Programming. I have the experience that I used DX library for before in C++. The DX library worked with simple functions, but the library of the JAVA does not work with functions.
How can I understand Java Class libraries?
| Not functions, but methods of Objects. That's a big difference, and the key to OO.
Simple example:
String x = new String("abcdef");
String y = x.substring(2);
Note the idea you start by getting a reference to an object of a particular type, here x is a String.
You then can ask x to do lots of different things, such ... |
1,217,777 | 1,217,784 | Convert LPCOLESTR to BSTR? | Any ideas on how to make a BSTR out of an LPCOLESTR? Silly thing to get hung up on..
| An LPCOLESTR is just a const wchar_t*, so you can use SysAllocString() to create a BSTR:
LPCOLESTR olestr = ...;
BSTR bstr = SysAllocString(olestr);
Be sure to call SysFreeString() when you're done with your BSTR. See also the MSDN documentation on BSTRs
|
1,217,796 | 1,218,056 | Does a "pure" IDispatch interface require a proxy/stub DLL? | ..for an out-of-process-server, or can I call a dispatch interface without registering a proxy/stub?
The interface in question is very high level, so performance is a non-issue, and I could make the whole thing registration-free, which is a big plus
| I'm pretty sure you don't need to provide a custom proxy/stub dll if you limit your interface(s) to automation-compatible types. In that case, the system can use the automation marshaler and doesn't need any additional help. I believe the automation-compatible types are the types that can fit into a VARIANT, e.g. simpl... |
1,217,923 | 1,217,931 | interrupt program in debugger when c++ exception is thrown | How can I make gdb interrupt (like in breakpoint) the program at the point where an exception is thrown, and interrupt again on rethrows and beginnings of the relevant catch blocks?
| Try catch throw and catch catch.
|
1,218,014 | 1,218,594 | Provide program arguments when debugging with Code::Blocks | I cant seem to work out how to add program arguments to the launch command for the codeblocks debugger. Any one know how to do this?
| I found it. Project --> Set programs arguments (i was looking all over project settings like visual studio has it)
|
1,218,133 | 1,218,145 | Parsing XML Encoded in UTF-8 | I am working with a Wikipedia XML dump that is encoded in UTF-8. Right now, I am reading in everything as std::string, so when I std::cout to the screen, foreign characters are displayed as jibberish.
The actual parsing process only looks for ASCII characters though, but when I write the parsed file to disk, I want to... | UTF-8 is the default encoding for XML documents. Just write it to your file. There is no point in converting it to Unicode and back again. If it is accidentally dumped to your screen, avert your gaze :-)
Removing ASCII characters like '{' will not cause a problem. UTF-8 is designed so that no byte in a multi-byte chara... |
1,218,355 | 1,218,361 | How to convert Win32 HRESULT to int return value? | I'm writing a Windows console application in C++ and would like to return zero on success and a meaningful error code on failure (i.e., S_OK should return 0, and E_OUTOFMEMORY should return a different return value than E_FAIL and so on). Is the following an okay approach?:
int wmain(int argc, wchar_t *argv[])
{
HR... | HRESULT is just a 32-bit integer, with each code being a different value, so what you are doing is what you want.
|
1,218,648 | 1,218,685 | "Ch++" or "ch+1" in C++? | While reading "C++ Primer Plus 5th edition", I saw this piece of code:
cin.get(ch);
++ch;
cout << ch;
So, this will lead to display the following character after ch. But, If I did it that way:
cin.get(ch);
cout << ch+1;
Now, cout will think ch is an int(try typecasting). So, why cout does so?
And ... | The reason this occurs is the type of the literal 1 is int. When you add an int and a char you get an int, but when you increment a char, it remains a char.
Try this:
#include <iostream>
void print_type(char)
{
std::cout << "char\n";
}
void print_type(int)
{
std::cout << "int\n";
}
void print_type(long)
{
... |
1,218,699 | 1,218,709 | Error when passing an object by reference | So I have a problem....
I've a method
void MainWindow::loadItems(const ArticleStore& store)
{
}
that I try to call like this inside the MainWindow class
ArticleStore store();
loadItems(store)
And I get this error
mainwindow.cpp:15: error: no matching function for call to ‘MainWindow::loadItems(ArticleStore ... | It's because
ArticleStore store();
is interpreted by the compiler as a function declaration.
That's explain why compiler is looking for ‘MainWindow::loadItems(ArticleStore (&)())’
You must write instead:
Article store; // With no parenthesis
|
1,218,800 | 1,218,967 | Eclipse CDT 5.x and cmake 2.6.x | According to what I see, cmake 2.6.x supports CDT 4.x. We already have CDT 6.x.
Is CDT 5.x and cmake 2.6.x are compatible at least?
Thanks
Dima
| Yes, it is.
The eclipse CDT 4.x project generated by cmake is compatible with next versions.
I use them everyday, and work like a charm:
cmake: version 2.6-patch 2 (Ubuntu 8.10)
eclipse: version 3.4.1
CDT: version 5.0.1
I have also tried to import those projects with CDT 6 and all it keep working. Would be really ba... |
1,218,807 | 1,218,854 | Counting the total of same running processes in C++ | I'm looking for a way to detect the # of running processes that has same process name.
In example, I ran notepad three times.
notepad.exe
notepad.exe
notepad.exe
So it will return 3.
I currently have these code to detect a running process, but not counting its running process quantity.
#include <iostream>
#include <win... | You are using the correct API, namely CreateToolhelp32Snapshot, Process32First and Process32Next. And as you are doing, you should be using the szExeFile member from the struct PROCESSENTRY32.
You are returning from your function when you find a match currently though. Instead you should be incrementing a counter and ... |
1,218,876 | 1,218,878 | Problem with using OpenGL's VBO | I just tried to render the first redbook example ( the white Quad ) by using VBOs.
It works fine with immediate mode and vertex arrays.
But when using VBOs the screen stays black. I think i must have missed something important.
init:
unsigned int bufIds[2];
glGenBuffers( 2, bufIds );
GLfloat vertices[] = {
0.25, ... | argh i just figured it out by trying to read back the contents of the buffer:
i need to allocate the buffer with 12 * sizeof( GLfloat ) instead of only 12
glBufferData( GL_ARRAY_BUFFER, 12 * sizeof( GLfloat ), vertices, GL_STATIC_DRAW );
my read back code
GLfloat vertices2[12];
glBindBuffer( GL_ARRAY_BUFFER, bufIds[0]... |
1,218,914 | 2,352,136 | Eclipse C++ compilation warning problem | Here a code to demonstrate an annoying problem:
class A {
public:
A():
m_b(1),
m_a(2)
{}
private:
int m_a;
int m_b;
};
This is an output on Console view:
make all
Building file: ../test.cpp
Invoking: GCC C++ Compiler
g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"test.d" -MT"... | According to the last comment on this bug report you should be able to click on the console view to jump to code in CDT 7.0.
It might be worth checking out the milestone builds to see if the grouping of error messages is better. If not raising a bug to attempt to group related messages would be a good idea.
|
1,218,947 | 1,218,960 | Convert a String in C++ Code | I'm learning C++ and developing a project to practice, but now i want to turn a variable(String) in code, like this, the user have a file that contains C++ code, but i want that my program reads that file and insert it into the code, like this:
#include <iostream>
#include <fstream>
#include <string>
#include <cstdlib>... | You're doing cout right? So obviously it gets displayed.
Maybe what you are trying to do is some code injection in a running process like this http://www.codeproject.com/KB/DLL/code_injection.aspx
|
1,219,005 | 1,219,022 | const pointers in STL containers | Hello fellow C++ programmers.
I have, what I hope to be, a quick question about STL containers:
std::list<std::string> l;
This statement compiles fine when used in some C++ sourcefile (with the appropriate includes). But
std::list<const std::string> m;
or
std::list<std::string * const> n;
fails to compile when using... | Technically, container elements do have to be assignable, however in std::list, list nodes are very rarely moved around, so once constructed they don't need to be copied (OK) or assigned (would cause an error).
Unless a compiler goes out of its way to test assignability, it's likely that instantiating many list operati... |
1,219,007 | 1,219,014 | C++ Template Metaprogramming - Is it possible to output the generated code? | I would like to debug some templated code to understand it better.
Unfortunately I'm new to template metaprogramming and it IS hard for me to get in.
When I try to output the preprocessed source files I get 125 000 lines of code :/
So is there a way I can see the generated Code? (The library I'm using is SeqAn)
| No it isn't. The preprocessor has nothing to do with template processing, which is performed by the compiler. Templates do not generate C++ code, any more than a function call does - they are an integral part of the C++ language itself.
|
1,219,112 | 1,219,184 | C++ Getting the size of a type in a macro conditional | Is there some way to do something like this in c++, it seems sizeof cant be used there for some reason?
#if sizeof(wchar_t) != 2
#error "wchar_t is expected to be a 16 bit type."
#endif
| I think things like BOOST_STATIC_ASSERT could help.
|
1,219,607 | 1,219,618 | Why do we need a pure virtual destructor in C++? | I understand the need for a virtual destructor. But why do we need a pure virtual destructor? In one of the C++ articles, the author has mentioned that we use pure virtual destructor when we want to make a class abstract.
But we can make a class abstract by making any of the member functions as pure virtual.
So my ques... |
Probably the real reason that pure virtual destructors are allowed is that to prohibit them would mean adding another rule to the language and there's no need for this rule since no ill-effects can come from allowing a pure virtual destructor.
Nope, plain old virtual is enough.
If you create an object with default i... |
1,219,693 | 1,219,707 | Can a C++ dll compiled using Visual Studio 2008 be used with Visual Studio 2005? | I'm going to be working with a C++ library written in plain C++ (not .NET and without MFC). The library is available compiled using both Visual Studio 2005 / Intel Fortran 9.1 and VS 2008 / Intel Fortran 10.1.
Obviously I'm going to grab the binaries for VS 2008 since that's the environment on my computer but I'm curi... | The biggest issue you will run into is the usage of the CRT. If the CRT (C RunTime) is statically linked into the DLL, you shouldn't have any issues.
However if the CRT is dynamically linked into the project you may run into trouble. Visual Studio 2005 and 2008 use different versions of the CRT and they cannot easily... |
1,219,821 | 1,219,832 | Syntax error in resource file. I don't understand | I have a .rc file:
#include "MainWindowResource.h"
MAINWINDOW_MENU MENU DISCARDABLE
BEGIN
POPUP "&File"
BEGIN
MENUITEM "&New\tCtrl+N", MAINWINDOW_MENU_FILE_NEW
MENUITEM "&Open\tCtrl+O", MAINWINDOW_MENU_FILE_OPEN
MENUITEM "&Save\tCtrl+... | What is MAINWINDOW_FILE_EXIT defined to be? You might find it has some bogus text as part of its definition, or a missing quote if it's a string.
Edit: You probably need BEGIN and END even for an empty POPUP.
|
1,219,825 | 1,256,203 | Build Managment: Eclipse project vs Eclipse Managed Make project | I am developing under Windows, and using Eclipse with CDT to develop C++ applications.
Now, for build management I can create a normal C++ project and Eclipse will completely manage the build (calling the g++ compiler with proper arguments), or I can create a Managed Make C++ project and Eclipse will manage the Makefil... | One consideration is, do you want to require that developers who work with your project must install and use Eclipse? It's not a value judgement about Eclipse, rather an assumption as to your audience and how familiar they are with your chosen tool. If a C++ programmer is familiar with Java/Eclipse it may not be a pr... |
1,219,827 | 1,219,833 | Qt, Mouse skipping, not updating every pixel, mouseMoveEvent() | I working on a simple paint program.
It seemed Qt (and KDE) would be a easy way to implement it.
I find Qt quite easy to work with, but now I have hit a problem.
When I draw something in my program the mouse skips if I move the mouse to fast.
like this:
It susposed to be like one long string.
I'm using mouseMoveEvent(... | Mouse events don't occur for each pixel as the mouse moves, on most operating systems. The message handlers (including KDE/linux) repeatedly show mouse movements, but pixels will often be skipped.
You'll need to track the last pixel location, and either draw a line, or add extra points in between the last position and... |
1,219,879 | 1,753,264 | Developing Console Like Apps For Palm OS | I'm learning C++, but i only develop console apps, because graphical C++ development is so much difficult, then i want to know if i can develop console like apps for Palm OS, what i want is this, compile this code for Palm OS for example:
// ClientFille.cpp
// Cria um arquivo sequencial.
#include <iostream>
using std:... | The only built-in stdin/stdout interface on Palm OS is the secret "network console". I wrote about this in an old blog entry at http://palmos.combee.net/blog/HiddenIOConsole.html. However, there's no C++ binding for this, so you'd need to make your own stream classes that call into these functions, and the old versio... |
1,219,951 | 1,219,977 | Win32API - How to get file name of process from process handle? | How can I get the file name of process from a process handle? I'm using Win32 C++ (Visual C++ Express Edition).
Thanks.
| Call GetModuleFileNameEx. Available as of Windows 2000.
DWORD WINAPI GetModuleFileNameEx(
__in HANDLE hProcess,
__in_opt HMODULE hModule,
__out LPTSTR lpFilename,
__in DWORD nSize
);
Use NULL for the second parameter to get the name of the EXE file.
|
1,220,223 | 1,220,271 | are there any tutorials to help a proficient c++ programmer learn c? | I became a professional programmer in the era of object oriented code, and have years of experience programming in C++. I often work on large projects that have years of legacy code in a mix of c++ and c.
I feel less comfortable working on pure c parts of systems. From programming in C++ I understand all the c syntax,... | In terms of organization, looking at the POSIX APIs, especially pthreads will give you a good idea of how to organize C code. The basic rules of good C project organization are:
Don't expose your structures. Use opaque types only.
Use the library and data type names as prefixes for function names.
Provide "create" and... |
1,220,265 | 1,220,277 | Best practice for fetching a collection of items from an object? | I'm dealing specifically with C++, but this is really language-agnostic.
Just to give some context into the problem... I have a tree/graph based structure where each node holds a collection of multiple items.
I have a class which encapsulates some generic collection (list, map, vector, LinkedList, whatever). I want t... | The Iterator pattern is generally considered a proper method to expose a list of elements from a collection agnostic to the actual internal representation of the collection. You could create your iterator in such a way that it returns read-only (const) references, or make copies of items on the fly as they're requested... |
1,220,275 | 1,220,280 | Where can I get information about the C/C++ linker in Visual Studio? | I'd like to learn more about C/C++ linker issues and troubleshooting in Visual Studio. I've had linker problems crop up from time to time and they are really annoying since you get such limited information from the linker error messages. I've seen a few not-so-detailed MSDN articles but nothing in depth.
Where can I ... | For a general understanding of linkers, read the book “Linkers and loaders”.
You can read it online: http://www.iecc.com/linker/.
I think that an in-depth look into Windows executables alone will be very useful:
http://msdn.microsoft.com/en-us/magazine/cc301805.aspx
http://msdn.microsoft.com/en-us/magazine/cc301808.asp... |
1,220,304 | 1,220,358 | Does source incompatibility always imply binary incompatibility? | Any examples demonstrating where source compatibility is broken yet binary compatibility is maintained is welcome.
| Old version:
struct inner {
int bar;
}
struct foo {
struct inner i;
};
void quux(struct foo *p);
New version:
struct inner2 {
int bar;
};
struct foo {
struct inner2 i;
};
void quux(struct foo *p);
Broken code:
struct foo x;
struct inner *i = &x.i;
i->bar = 42;
quux(&x);
Since the only difference is the n... |
1,220,396 | 1,220,407 | Keeping the contents of an array after its function call ends. (C++) | Lets say I have the following code.
double *return_array(void) {
double foo[2];
foo[0] = 5;
foo[1] = 6;
cout << foo << endl;
cout << foo[0] << endl << foo[1] << endl;
return foo;
}
double *bar = return_array()
cout << bar << endl;
cout << bar[0] << endl << bar[1] << endl;
Now, bar and foo are still ... | Typically you would pass in your pre-allocated memory into the function:
int barsize = 2;
double *bar = new double[barsize];
fill_array( bar, barsize );
cout << bar << endl;
cout << bar[0] << endl << bar[1] << endl;
delete [] bar;
void fill_array( double *foo, int foosize )
{
if ( foosize < 2 )
return;
foo[0]... |
1,220,499 | 1,220,576 | How is a "handshake" generally implemented with regards to Named Pipes | I need to implement a handshake type protocol in to a small Linux program that uses named pipes to communicate with other processes. I've searched for a general implementation pattern for a handshake type protocol when using named pipes but I've not been able to turn anything up...
I simply can't believe that there isn... | In typical usage, the processes rely on blocking to handshake. The writer process opens the pipe for writing, the reader process opens the pipe for reading, and whichever happens first blocks until the other process opens its side. This can be extended to use nonblocking IO on the reader side.
Named pipes are most us... |
1,220,507 | 1,220,514 | Initialising a std::string from a character | There doesn't seem to be a standard constructor so I've taken to doing the following
void myMethod(char delimiter = ',')
{
string delimiterString = 'x';
delimiterString[0] = delimiter;
// use string version ...
}
Is there a better way to do this?
| std::string has a constructor that will do it for you:
std::string delimiterString(1, delimiter);
The 1 is a size_t and denotes the number of repetitions of the char argument.
|
1,220,518 | 1,220,521 | What is wrong with this usage of the new operator? | Is this allowed?
Object::Object()
{
new (this) Object(0, NULL);
}
| Using new(this) will re-construct member variables. This can result in undefined behavior, since they're not destructed first. The usual pattern is to use a helper function instead:
class Object {
private:
void init(int, char *);
public:
Object();
Object(int, char *);
};
Object::Object() {
init(0, NULL);
}
Ob... |
1,220,826 | 1,221,064 | Changing wallpaper on Linux programmatically | How would I change the wallpaper on a Linux desktop (using GNOME) within a C/C++ program? Is there a system API to do it?
| Though the question was gnome-specific, there's also a way to deal with the wallpaper that is not depepndant on the higher layer toolkits. You should be able to deal with the root window (which the wallpaper is, in fact) by studying the source of xsetroot.c, the most interesting part of which I copypaste here:
static v... |
1,220,839 | 1,246,863 | Can Eclipse CDT do auto-complete when using typedefs? | For all my code Eclipse's autocomplete function is working fine, except when I use a typedef.
Example code (someclass.hh):
typedef std::vector<int> IntVector;
class SomeClass {
void sort_int_vector(IntVector &iv) {
iv.//eclipse auto complete does not work. (ctrl-space)
}
}
How can I configure Eclipse to do auto... | This works for me using Galileo, I would have expected this to be working for a couple of releases now.
Check that the CDT is able to find the appropriate include file. You can check the Includes under the project explorer.
If it isn't finding your includes, check your project properties -> C/C++ General -> Paths and ... |
1,220,974 | 1,221,127 | Does MemoryDC occupied memory or the memory on video card? | I am using the following code to create a compatible DC:
m_pDC=new CDC();
VERIFY(m_pDC->CreateCompatibleDC(sampleDC);
CBitmap bitmap;
if (bitmap.CreateCompatibleBitmap(sampleDC, rect.Width(), rect.Height()))
{
m_pOldBitmap = m_pDC->SelectObject(&bitmap);
}
My question is does CDC CBitmap occupied memory ?
If it is... | Memory in CreateCompatibleBitmap are allocated from a system-wide pool that's typically limited to about 200 Megabytes on 32-bit versions of Windows.
Since WinNT4.0 CreateBitmap() API allocates the bitmap in kernel-mode paged memory. In WinNT4 it was impossible to create bitmaps greater than 48 MB.
What was your limit?... |
1,221,185 | 1,221,238 | Identical build on different systems | I have 3 build machines. One running on windows 2000, one with XP SP3 and one with 64bit Windows Server 2008.
And I have a native C++ project to build (I'm building with visual studio 2005 SP1).
My goal is to build "exactly" the same dll's using these build machines.
By exactly I mean bit by bit (except build timestamp... | You might think that compiling is purely deterministic (identical inputs give identical output, every time) but this need not be the case. For example, consider the optimiser - this is going to need some memory to work in, probably more for higher optimisation methods. If on one machine a memory allocation fails (becau... |
1,221,244 | 1,221,262 | C++ Real time console app, simultaneous input and output | I'm writing a quick server app for something so don't really want to write a full GUI. However the problem is that the main part of the server, however the console window will only allow input or output at a time.
Many games ive played that have a console in them (usually needs activating in some way or another) they s... | Sounds like you should have a look at curses
ncurses
pdcurses
|
1,221,300 | 1,221,362 | C++ error detection in Visual Studio 2005 | Coming from a different development environment (Java, mostly) I'm trying to make analogies to habits I'm used to.
I'm working with a C++ project in Visual Studio 2005, the project takes ~10 minutes to compile after changes. It seems odd that if I make a small syntactical error, I need to wait a few good minutes to get... | The feature you are asking for will be available in Visual Studio 2010. Here is a detailed link of the feature details that will be available.
For now, as others have suggested, you can use Visual Assist which can help a little bit.
These are called Squiggles BTW.
|
1,221,902 | 1,221,913 | Programs compiles in g++ but exits with linker errors in gcc | I'm trying out the solution to a question about specialized template classes.
This code with a compiles fine in g++, but throws up linker errors when compiled with gcc. What's the cause of these errors ?
$ g++ traits2.cpp
$ gcc traits2.cpp
/tmp/ccI7CNCY.o: In function `__static_initialization_and_destruction_0(int, i... | When you compile with gcc, the C++ libraries are not linked in by default. Always build C++ code with g++.
|
1,222,264 | 1,238,715 | C++ mysql and boost asio header conflict | There seems to be a conflict with the windows headers between the mysql c-api and boost::asio.
If I include mysql first I get:
boost/asio/detail/socket_types.hpp(27) : fatal error C1189: #error : WinSock.h has already been included
#if defined(BOOST_WINDOWS) || defined(__CYGWIN__)
# if defined(_WINSOCKAPI_) && !defi... | The macro redefinition is only a warning. Your code should still compile and link.
I think your code will even work without any problem.
|
1,222,296 | 1,222,438 | Building a vector from components contained in another vector type | I have a code that looks something like this:
struct First
{
int f1;
int f2;
};
struct Second
{
First s1;
int s2;
};
std::vector < Second > secondVec;
Second sec;
sec.s1 = First();
secondVec.push_back(sec);
secondVec.push_back(sec);
std::vector < First > firstVec;
firstVec.reserve(secondVec.size()... | If you have TR1 or Boost available, you could try this:
std::transform(secondVec.begin(),
secondVec.end(),
std::back_inserter(firstVec),
std::tr1::bind(&Second::s1, _1));
|
1,222,340 | 1,225,309 | Aspect ratios - how to go about them? (D3D viewport setup) | Allright - seems my question was as cloudy as my head. Lets try again.
I have 3 properties while configuring viewports for a D3D device:
- The resolution the device is running in (full-screen).
- The physical aspect ratio of the monitor (as fraction and float:1, so for ex. 4:3 & 1.33).
- The aspect ratio of the source ... | I'm assuming what you want to achieve is a "square" projection, e.g. when you draw a circle you want it to look like a circle rather than an ellipse.
The only thing you should play with is your projection (camera) aspect ratio. In normal cases, monitors keep pixels square and all you have to do is set your camera aspec... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.