I am using asin to calculate the angle. The code is as below :
double FindAngle(const double theValue)
{
return asin(theValue);
}
FindAngle returns a -0.0 (signed zero), when the argument theValue = -0.0. Now, how do i get rid of the minus sign from the return value.
...
Cleaning up old c/c++ code that used hardcoded integer literals instead of enums, it is tedious to find places where the function-declaration has been properly refactored but not the body. e.g.
enum important {
little = 1,
abit = 2,
much = 3
};
void blah(int e)
{
// magic stuff here
}
void boing(int e) { ... }
void guck(impor...
I'm getting memory allocation errors (and a subsequent crash) on the following simplified code:
std::wstring myKey = L"str_not_actually_constant";
MyType obj;
Read( obj );
std::map<std::wstring, MyType> myMap;
myMap[myKey] = obj; // Sometimes allocation error (1)
...
Read( MyType& obj )
{
obj.member1 = ReadFromFuncThatMayBeProblem()...
On my Ubuntu computer, when I ask for an object/variable's type using typeid, I get a weird-looking name using the type_info::name method. (By "weird" I mean that it's different from what I'd expect to get on Windows.)
I Googled around a bit, and found out that RTTI names are implementation-specific. Problem is, I want to get a type's n...
How do I get the list of all environment variables in C and/or C++. I know that getenv can be used to read an environment variable, but how do I list them all?
...
Greetings,
I am sorry for bothering, I'll show the question:
I am trying to export some functions written in c++ in a DLL in order to import them in a C# Application running on Visual Studio.
I make the export as reported in the following code,
tobeexported.h:
namespace SOMENAMESPACE
{
class __declspec(dllexport) SOMEC...
After installing a new build machine, I found out it came with 6.0.10 of the standard C++ library
-rw-r--r-- 1 root root 1019216 2009-01-02 12:15 libstdc++.so.6.0.10
Many of our target machines, however, still use an older version of libstdc++, for example:
-rwxr-xr-x 1 root root 985888 Aug 19 21:14 libstdc++.so.6.0.8
Apparently ...
I n my application i have upt o millions of short strings (mostly shorter than 32 characters). I want to implement a search box with a attached list that contains only elements that contain the whole string entered in the search box. How can i prebuild a index to find such strings fast? All sorted STL containers check the whole string.
...
Hello I have this code in C#:
float n = 2.99499989f;
MessageBox.Show("n = " + n.ToString("f2", CultureInfo.InvariantCulture));
And this code in C++:
float n = 2.99499989f;
printf("n = %.2f", n);
First one outputs 3.00.
Second one outputs 2.99.
I have no clue why this is happening.
Update:
I also tried Objective-C NSLog and the o...
Hello all, I'm facing a nuisance when coding my unit tests using UnitTest++. I'm wondering how to access private member class fields in a clean way (or maybe any way...)
By now, I have a solution to access protected members using a class fixture deriving from the class under test. The following code shows the idea:
struct MyFixture : C...
How to wait and notify like in Java In C/C++ for shared memory between two or more thread?I use pthread library.
...
Hello everyone,
Many of my programs output huge volumes of data for me to review on Excel. The best way to view all these files is to use a tab deliminated text format. Currently i use this chunk of code to get it done:
ofstream output (fileName.c_str());
for (int j = 0; j < dim; j++)
{
for (int i = 0; i < dim; i++)
output...
I have a C# COM DLL and I want to call its methods throught c++ methods.
How do I make this?
...
I was wondering how can you use operators along with 'this'. To put an example:
class grd : clm
{
inline int &operator()(int x, int y) { return g[x][y]; }
/* blah blah blah */
};
grd grd::crop(int cx1, int cy1, int cx2, int cy2)
{
grd ngrd(abs(cx1-cx2), abs(cy1-cy2));
int i, j;
//
for (i = cx1; i < cx2; i++)
...
Hello i am learning qt and trying to upload a file using QFtp i wrote the folowing code
this->connect(this->ftp, SIGNAL(done(bool)), this, SLOT(ftpDone(bool)));
this->connect(this->ftp, SIGNAL(dataTransferProgress(qint64, qint64)), this, SLOT(dataTransferProgress(qint64, qint64)));
this->connect(this->ftp, SIGNAL(stateChanged(int)), thi...
Assuming a correct instantiation in the indicated comment, is the following expression legal and portable C++? Why or why not?
std::mem_fun</*…*/>(&(std::vector<int>::clear))
...
I'm tired of thinking how the hell my coodinates are working at each case.
I heard that I could flip the Y-axis by this code:
glScalef(1, -1, 1);
But should I? Doesnt this break some other external functions and lighting etc?
...
I have a school assignment which consists of programming a scanner/lexical analyzer for a specified simple language. The scanner has to be programmed in C++.
This type of assignment has been used since the 90's and, although still a valid excersise, I consider it to be a little antiquated and a little boring.
I have gotten permission t...
I have a shared C library, libfoo.so, for which I'm creating a JNI interface. In order to compile the JNI interface library, libfoojni.so, compiler include search paths must be specified. For example, on Linux (using GCC) the following compiler flags are required: -I${JAVA_HOME}/include -I${JAVA_HOME}/include/linux.
Unfortunately, the l...
Hello. I'm trying to do a base template class which parameter T must be a structure.
When I use a variable declared as being of type T (both in the template class as in a class that extends it defining T) GCC fails to compile it:
GCC error: invalid use of incomplete
type ‘struct x'
Despite it working on VC I understand that it d...