I have the following bit of code, however when compiling it with GCC 4.4 with various optimization flags I get some unexpected results when its run.
#include <iostream>
int main()
{
const unsigned int cnt = 10;
double lst[cnt] = { 0.0 };
const double v[4] = { 131.313, 737.373, 979.797, 731.137 };
for(unsigned int i = 0; i ...
I'm working on a cross-platform app for Windows and Mac OS X, and I have a problem with two standard C library functions:
strtod() - string-to-double conversion
sprintf() - when used for outputting double-precision floating point numbers)
Their GCC and MSVC versions return different results, in some digits of mantissa. But it plays a...
Hi,
I am trying to compile my c program in ubuntu 9.10 (gcc 4.4.1).
I am getting this error:
Rect.cpp:344: error: ‘memset’ was not declared in this scope
But the problem is I have already included in my cpp file:
#include <stdio.h>
#include <stdlib.h>
And the same program compiles fine under ubuntu 8.04 gcc 4.2.4).
Please tell m...
Hi Guys,
I have a dll, it exports a function...
extern "C"
int __stdcall
MP_GetFactory( gmpi::IMpUnknown** returnInterface )
{
}
I compile this with Code::Blocks GCC compiler (V3.4.5). Problem: resulting dll exports decorated function name...
MP_GetFactory@4
This fails to load, should be plain old...
MP_GetFactory
I've researche...
Recently I tried compiling program something like this with GCC:
int f(int i){
if(i<0){ return 0;}
return f(i-1);
f(100000);
and it ran just fine. When I inspected the stack frames the compiler optimized the program to use only one frame, by just jumping back to the beginning of the function and only replacing the arguments to...
How does objdump manage to display source code? Is there a reference to the source file in the binary? I tried running strings on the binary and couldn't find any reference to the source file listed...
Thanks.
...
Can anybody explain me what effect these two instructions cause in the assembly code generated by gcc for x86 machines:
push %ebp
movl %esp, %ebp
...
I'm updating some old code that has several POD structs that were getting zero'd out by memset (don't blame me...I didn't write this part). Part of the update changed some of them to classes that use private internal pointers that are now getting wiped out by the memset.
So I added a [non-virtual] reset() method to the various structs a...
warning: passing argument 1 of 'bsearch' makes pointer from integer without a cast
and the corresponding code is
Parent =bsearch((const size_t)ParentNum, ClauseVector, Size,
sizeof(CLAUSE),pcheck_CompareNumberAndClause);
the compilar is gcc.
here CLAUSE is defined as *CLAUSE.
@Paul This following more informati...
Hello,
uname -mr: B.11.23 ia64
g++ --version: g++ (GCC) 4.4.0
java -version:
Java(TM) SE Runtime Environment (build 1.6.0.06-jinteg_20_jan_2010_05_50-b00)
Java HotSpot(TM) Server VM (build 14.3-b01-jre1.6.0.06-rc1, mixed mode)
I'm trying to run a Java application that uses JNI. It is crashing inside the JNI code with the following (...
This question is mostly academic. I ask out of curiosity, not because this poses an actual problem for me.
Consider the following incorrect C program.
#include <signal.h>
#include <stdio.h>
static int running = 1;
void handler(int u) {
running = 0;
}
int main() {
signal(SIGTERM, handler);
while (running)
;
pr...
I'm trying to make my project compile under GCC (Visual Studio compiles it flawlessly).
I have a custom assert function which throws a wstring message. A part of it is the _ FUNCTION_ macro, which I "unicodize" using the WIDEN macro from MSDN
#define WIDEN2(x) L ## x
#define WIDEN(x) WIDEN2(x)
It compiles okay in MSVC, but it prints ...
In Apple's The Objective-C Programming Language: Defining a Class the section named "Redefining self" recommends that that class methods allocate and return instances use 'self' only to allocate an instance and then refer only to that instance. Thus, I have a number of subclasses, that have class methods along the lines of:
+ (id)scroll...
I've been reading through the Linux kernel (specifically, 2.6.11).
I came across the following definition:
#define unlikely(x) __builtin_expect(!!(x), 0)
(from linux-2.6.11/include/linux/compiler.h:61 lxr link)
What does !! accomplish? Why not just use (x)?
See also:
How does logical negation work in C?
Double Negat...
I'm having a problem with the MinGW implementation of GCJ. I read that you have to install libiconv before you can use it. However, the documentation wasn't very specific, and it did not say where to extract the binaries and developer files (libiconv-bin and libiconv-lib). I have tried the following paths:
$p = c:\mingw
$p\libiconv-1.9.2...
This compiles fine in Visual studio, but why not in XCode?
class A()
{};
someMethod(A& a);
someMethod(A()); //error: no matching function call in XCode only :(
Is this bad form?
it seems annoying to have to write the following every time:
A a;
someMethod(a); //successful compile on Xcode
Am i missing something? I am not very...
Short story:
I can't make precompiled headers work properly with gcc -c option.
Long story:
Folks, I'm using gcc-4.4.1 on Linux and before trying precompiled headers in a really large project I decided to test them on simple program. They "kinda work" but I'm not happy with results and I'm sure there is something wrong about my setup....
Howdy,
I am attempting to use the fully qualified name of my nested class as below, but the compiler is balking!
template <class T> class Apple {
//constructors, members, whatevers, etc...
public:
class Banana {
public:
Banana() {
//etc...
}
//other constructors, members, etc...
};
};...
Note the comment below. It cannot compiled on UVA because of a bug in GCC.
#include <cstdio>
#include <cstring>
#include <cctype>
#include <map>
#include <stdexcept>
class Board {
public:
bool read(FILE *);
enum Colour {none, white, black};
Colour check() const;
private:
struct Index {
size_t x;
...
$ gcc -S buffer-overflow.c && cat buffer-overflow.s
_foo:
pushl %ebp ;2
movl %esp, %ebp ;3
subl $16, %esp ;4
movl LC1, %eax ;5
movl %eax, -4(%ebp) ;6
leal -4(%ebp), %eax ;7
leal 8(%eax), %edx ;8
movl $_bad, %eax ;9 ...