Hi,
I'm thinking of using pure/const functions more heavily in my C++ code. (pure/const attribute in GCC)
However, I am curious how strict I should be about it and what could possibly break.
The most obvious case are debug outputs (in whatever form, could be on cout, in some file or in some custom debug class). I probably will have a ...
pure is a function attribute which says that a function does not modify any global memory.
const is a function attribute which says that a function does not read/modify any global memory.
Given that information, the compiler can do some additional optimisations.
Example for GCC:
float sigmoid(float x) __attribute__ ((const));
float c...
I need to answer a basic question from inside my C program compiled by GCC for Linux: how much of process heap is currently in use (allocated by malloc) and how much resides if free heap blocks. GNU implementation of standard library has mallinfo function which reports exactly what I need, but it only usable with 32-bit configurations an...
Ruby Enterprise Edition fails to compile from sources with GCC 4.5, but sucessfully compiles with 4.3.3.
Actually, not sure if it's about GCC, but, in fact, i686 Arch linux system with laest updates won't compile RE.
Compilation fails with the message:
mkdir -p .ext/common
make PRELIBS='-Wl,-rpath,/opt/ruby-enterprise-1.8.7-2010.01/lib...
As far as I've understood, it is not possible to link libraries that use different versions of GCC's Application Binary Interface (ABI). Are there ABI changes to every version of GCC? Is it possible to link a library built with 4.3.1 if I use, say, GCC 4.3.2? Is there a matrix of some sort that lists all the ways I can combine GCC versio...
Is it possible to convert an object file .o that was created from a .c source code to .exe?
And if it is possible is there a direct command using gcc?
...
I found the only one simillar question but that's for linux and xcode only...
http://stackoverflow.com/questions/854675/is-it-possible-to-set-up-a-linux-box-with-distcc-to-build-my-xcode-projects
im really interested to use OSX GCC for OPENBSD BOX. because my server is really slow, and all I need is file sharing and printing at home. I...
Hello, I'm building a Windows dynamic library using the MinGW toolchain.
To build this library I'm statically linking to other 2 which offer an API and I have a .def file where I wrote the only symbol I want to be exported in my library.
The problem is that GCC is exporting all of the symbols including the ones from the libraries I'm l...
In MSVC++ #include files are searched for differently depending on whether the file is enclosed in "" or <>. The quoted form searches first in the local folder, then in /I specified locations, The angle bracket form avoids the local folder.
This means, in MSVC++, its possible to have header files with the same name as runtime and SDK he...
template<typename T>
class Base
{
protected:
Base() {}
T& get() { return t; }
T t;
};
template<typename T>
class Derived : public Base<T>
{
public:
Base<T>::get; // Line A
Base<T>::t; // Line B
void foo() { t = 4; get(); }
};
int main() { return 0; }
If I comment out lin...
I'm running gcov over some C code with a switch statement. I've written test cases to cover every possible path through that switch statement, but it still reports a branch in the switch statement as not taken and less than 100% on the "Taken at least once" stat.
Here's some sample code to demonstrate:
#include "stdio.h"
void foo(int ...
I'm trying to compile a wireless network card driver for my Linux box and I ran into a problem with the Make command. During the compilation process I normally see warnings on some of the C files that being are compiled; despite the warnings these files were still able to be compiled to an object file.
When the Make process comes to a f...
Given that I have a pointer to a function (provided by dlsym() for example) and a linked list of typed arguments, how can I construct a C function call with those arguments?
Example:
struct param {
enum type { INT32, INT64, STRING, BOOL } type;
union { int i32; long long i64; char *str; bool b; } value;
struct param *next;
};...
Unfortunately yes.
I have my shared library compiled, the linker doesn't complain about not finding it but still I get undefined reference error. Thinking that I might be doing something wrong I did a little research and found this nice, simple walkthrough:
http://www.adp-gmbh.ch/cpp/gcc/create_lib.html
which I've followed to the lett...
Hello,
We're building our project (with Xcode 3.2.2 on Mac OS X 10.6.3, GCC 4.0.1) using the -fvisibility=hidden flag.
We mark the classes we want to be visible with __attribute__((visibility("default"))).
For further optimization, should we be marking with __attribute__((visibility("hidden"))) the methods inside these classes that shou...
When I have conflicting definitions of the ivars of a class in objective-c (not redeclaring the class in the same file, but rather naming the same class with diff ivars, no warnings or better yet errors are issued by the compiler. However, both sets of ivars are useable by the appropriate methods in the respective files. For instance
...
While debugging a crash, I came across this issue in some code:
int func()
{
char *p1 = malloc(...);
if (p1 == NULL)
goto err_exit;
char *p2 = malloc(...);
if (p2 == NULL)
goto err_exit;
...
err_exit:
free(p2);
free(p1);
return -1;
}
The problem occurs when the first malloc fails. B...
Hello everyone,
I've not visited this site with a question, so I'm a bit clumsy with the interface, but here goes...
When I examine the code generated by gcc -v -o proggy.exe proggy.o I find that the command line expands into a large bunch of library options and libraries, all of which are linked using collect2.exe. What happened to ...
Hello I have a problem with compiling a ghostscript from ports in openbsd 4.7.
SO i have jpeg-7 installed, I have latest port tree for obsd4.7.
===> Building for ghostscript-8.63p11
mkdir -p /usr/ports/pobj/ghostscript-8.63p11/ghostscript-8.63/obj
gmake LDFLAGS='-L/usr/local/lib -shared' GS_XE=./obj/../obj/libgs.so.11.0 STDIO_IMPLEMEN...
Why does
class A;
template<typename T> class B
{
private:
A* a;
public:
B();
};
class A : public B<int>
{
private:
friend B<int>::B<int>();
int x;
};
template<typename T>
B<T>::B()
{
a = new A;
a->x = 5;
}
int main() { return 0; }
result in
../src/main.cpp:15: error: invalid use of constructor ...