I often use the execv() function in C++ but if some of the arguments are in C++ strings. It annoys me that I cannot do this:
const char *args[4];
args[0] = "/usr/bin/whatever";
args[1] = filename.c_str();
args[2] = someparameter.c_str();
args[3] = 0;
execv(args[0], args);
This doesn't compile because execv() takes char *const argv[]...
inline int factorial(int n)
{
if(!n) return 1;
else return n*factorial(n-1);
}
As I was reading this, found that the above code would lead to "infinite compilation" if not handled by compiler correctly.
How does the compiler decide whether to inline a function or not ?
...
We are trying to look at optimizing our localization testing.
Our QA group had a suggestion of a special mode to force all strings from the resources to be entirely contained of X. We already API hijack LoadString, and the MFC implementation of it, so doing it should not be a major hurdle.
My question is how would you solve the forma...
How can I find out the decorated name that will be asigned to each method name ? I'm trying to find out what the decorated name is , so that I may export it , in a DLL .
...
In the following code, both amp_swap() and star_swap() seems to be doing the same thing. So why will someone prefer to use one over the other? Which one is the preferred notation and why? Or is it just a matter of taste?
#include <iostream>
using namespace std;
void amp_swap(int &x, int &y)
{
int temp = x;
x = y;
y = temp;...
Hi all,
Loop unwinding is a common way to help the compiler to optimize performance. I was wondering if and to what extent the performance gain is affected by what is in the body of the loop:
number of statements
number of function calls
use of complex data types, virtual methods, etc.
dynamic (de)allocation of memory
What rules (of...
You can, obviously, put a variable declaration in a for loop:
for (int i = 0; ...
and I've noticed that you can do the same thing in if and switch statements as well:
if ((int i = f()) != 0) ...
switch (int ch = stream.get()) ...
But when I try to do the same thing in a while loop:
while ((int ch = stream.get()) != -1) ...
The ...
I am responsible for the User Interface of an application written completely in Visual C++ using MFC and some third-part controls. I would like to use C# (WinForms or even better WPF) to improve the application look&feel.
I would like some advices about how to do it. Links, articles, examples...
Right now the user interface is isolate...
I saw Scott Meyers' "Effective C++" third edition book having a small section on "Template Programming".
Any other book/links containing information on "effective" usage of templates ?
...
I am working on a collection MATLAB, Java, and C/C++ components that all inter-operate, but have distinctly different compilation/installation steps. We currently don't compile anything for MATLAB, use maven2 for our Java build and unit tests, and use autotools for our C/C++ build and unit tests.
I would like to move everything to a si...
How do I set the initial width of a QDockWidget?
I have implemented the sizeHint function but what next?
...
I have a client who is still using Visual Studio 6 for building production systems. They write multi-threaded systems that use STL and run on mutli-processor machines.
Occasionally when they change the spec of or increase the load on one of their server machines they get 'weird' difficult to reproduce errors...
I know that there are ...
I often need to design a dialog in Delphi/C++Builder that allows various properties of an object to be modified, and the code to use it typically looks like this.
Dialog.Edit1.Text := MyObject.Username;
Dialog.Edit2.Text := MyObject.Password;
// ... many more of the same
if (Dialog.ShowModal = mrOk)
begin
MyObject.Username := Dialog...
We have a fairly large code base, 400K LOC of C++, and code duplication is something of a problem. Are there any tools which can effectively detect duplicated blocks of code?
Ideally this would be something that developers could use during development rather than just run occasionally to see where the problems are. It would also be nice...
Hi all,
I installed wxWidgets 2.8.9 on a Windows XP SP2 box and built the library according to the directions and now I'm trying to get the Hello World! tutorial app to build from within Eclipse and I'm just missing something apparently. Any idea how to get Cygwin, Eclipse and wxWidgets to play nice together?
...
I thought this would be really simple but it's presenting some difficulties. If I have
string name = "John";
int age = 21;
How do I combine them to get a single string "John21"?
...
Can pipes be used across LAN computers?
In particular I'm looking for Windows, but if you have more info on other platforms, that will also help others who find this thread later.
...
If I have a native C++ windows program (i.e. the entry point is WinMain) how do I view output from console functions like std::cout?
...
Should I create two CFile objects and copy one into the other character by character? Or is there something in the library that will do this for me?
...
Why are pipes considered dangerous to use? What can be done to avoid these security issues?
I'm mostly interested in Windows, but if you have other OS information, please provide.
...