I need to force xcode/gcc to search the default system header search paths BEFORE searching my project HEADER_SEARCH_PATHS.
Any idea how I can accomplish this?
Using C++ and GCC, can I declare an extern variable that uses a specific address in memory?
Something like
int key attribute((__at(0x9000)));
AFAIK this specific option only works on embedded systems. If there is such an option for use on the x86 platform, how can I use it?
I want to calculate time elapsed during a function call in C, to the precision of 1 nanosecond.
Is there a timer function available in C to do it?
If yes please provide a sample code-snippet.
Pseudo code
Timer.Start()
foo();
Timer.Stop()
Display time elapsed in execution of foo()
Environment details: - using gcc 3.4 compiler on a RHEL machine
I'm looking at using SSE and I gather aligning data on 16byte boundaries is recommended. There are two cases to consider:
float data[4];
struct myystruct
{
float x,y,z,w;
};
I'm not sure the first case can be done explicitly, though there's perhaps a compiler option I could use? In the second case I remember being able to control packing in old versions of GCC several years back, is this still possible?
Hello,
gcc 4.4.1 c89
I have the following code and I get a warning:
unless class storage specifier in empty declaration
static enum states
{
ACTIVE,
RUNNING,
STOPPED,
IDLE
}
However, if i remove the static keyword I don't get that warning.
I am compiling with the following flags:
-Wall -Wextra
Many thanks for any suggestions,
I have trouble compiling a class, which has function pointers as member variables. The pointers are to functions which take an instance of a class as argument.
Like
template<class T, int N>
double (*f)(Vector<T,N> v);
I get "error: data member 'f' cannot be a member template" Compiler is gcc 4.2.
Hello,
Is there a way in gcc/g++ 4.* to write a macro that expands into several lines?
The following code:
#define A X \ Y
Expands into
X Y
I need a macro expanding into
X
Y
Hi All,
in a pre-compiled header if I do:
#define DS_BUILD
#define PGE_BUILD
#define DEMO
then in source I do:
#if (DS_BUILD && DEMO)
---- code---
#elif (PGE_BUILD && DEMO)
--- code---
#else
--- code ---
#endif
Do I get an error that states: error: operator '&&' has no right operand
I have never seen this before. I am using XCode 3.2, GCC 4.2 on OS X 10.6.3
related to http://stackoverflow.com/questions/2520535/gcc-multi-dim-array-or-double-pointer-for-warning-free-compile , is there a way to return so-called "decayed array pointer" from a function? in summary (suppose 2 dim array) returning int (*a)[5] format rather than int** format?
as far as I see, when returned int** pointer is sent to another function waiting (int*)[] parameter, it is not working correctly.
I've often seen that people create objects in C++ using
Thing myThing("asdf");
Instead of
Thing myThing = myThing("asdf");
This seems to work (using gcc), at least as long as there are no templates involved. My question now, is the first line correct and if so should I use it?
Hi,
I have installed "Damn Small Linux" on my home computer for doing C development in unix. But the distribution doesn't by default come with the C development environment and I am facing some issues when trying to install the gcc.
Is there any other small Linux distribution which by default has the required packages for the C development. And also I don't want additional software which takes up lot of space but still would like to have the graphical environment.
Thanks
Hi,
What is the difference between sizeof(3.0) and sizeof(3.0f)
I was expecting both of them to give the same result (sizeof float)..but its different.
In 32 bit machine,gcc compiler,
sizeof(3.0f) =4
sizeof(3.0) = 8
Why so?
I'm doing a library that makes extensive use of a thread local variable.
Can you point to some benchmarks that test the performances of the different ways to get thread local variables in C++:
C++0x thread_local variables
compiler extension (Gcc __thread, ...)
boost::threads_specific_ptr
pthread
Windows
...
Does C++0x thread_local performs much better on the compilers providing it?
My Herb Schildt book on C++ says: "... In C++, if a function is declared as returning a value, it must return a value." However, if I write a function with a non-void return type and do not return anything, the compiler issues a warning instead of an error: "Control reaches end of non-void function."
I use gcc (MinGW) and have set the -pedantic flag.
I cannot figure out why this segment gives unresolved overloaded function error (gcc version 4.3.4 (Debian 4.3.4-6)):
#include <algorithm>
#include <boost/function.hpp>
int main {
typedef boost::function2<const int&, const int&, const int&> max;
max m(static_cast<max>(&std::max<int>));
}
can you help me, thanks
I'm looking for a way to collect the dependencies from Flex ActionScript and MXML files. I was hoping that mxmlc could spit them out (like gcc's -M option), but its option list doesn't seem to have anything relevant. I could write a parser, but would prefer not to reinvent the wheel if it has already been done, particularly given the two very different languages involved. Is there a program available to do this for me?
The following example is working when I manualy replace T wirh char *, but why is not working as it is:
template <typename T>
class A{
public:
A(const T _t) { }
};
int main(){
const char * c = "asdf";
A<char *> a(c);
}
When compiling with gcc, I get this error:
test.cpp: In function 'int main()':
test.cpp:10: error: invalid conversion from 'const char*' to 'char*'
test.cpp:10: error: initializing argument 1 of 'A<T>::A(T) [with T = char*]'
Hello,
gcc 4.4.3 c89
I am creating a client server application and I will need to implement some callback functions.
However, I am not too experienced in callbacks. And I am wondering if anyone knowns some good reference material to follow when designing callbacks. Is there any design patterns that are used for c. I did look at some patterns but there where all c++.
Many thanks for any suggestions,
Under what circumstances will the "False" part of the following code be executed?
x = 20;
y = -30;
if (x > y) {
// True part
}
else {
// False part
}
NB: Language is C, compiler is gcc (although some other compilers may also do the same thing).
So this is probably a long shot, but is there any way to run a C or C++ file as a script? I tried:
#!/usr/bin/gcc main.c -o main; ./main
int main(){ return 0; }
But it says:
./main.c:1:2: error: invalid preprocessing directive #!
Consider the following code:
class A {
A(const A&);
public:
A() {}
};
int main() {
const A &a = A();
}
This code compiles fine with GCC, but fails to compile with Visual C++ with the following error:
test.cc(8) : error C2248: 'A::A' : cannot access private member declared in class 'A'
test.cc(2) : see declaration of 'A::A'
test.cc(1) : see declaration of 'A'
So is it necessary to have a copy constructor accessible when binding a temporary to a reference?
X.c >>
-------------------------
int i;
main ()
{
fun ();
}
-------------------------
Y.c >>
int i;
fun ()
{
}
why does these two files compile with no error ? (using GCC)
but if i use int i = 10;
throws multiple definition error
Hi,
I'm using ".align 16 \n\t" in some inline ARM assembly that is implementing some loops
to align it on a 16 byte boundary however gcc asm compiler is complaining that alignement
is too large
i want to implement -falign-loops=16 in asm for a particular loop
Thanks
This was a bug I found in a server application using Valgrind.
struct Foo
{
Foo(const std::string& a)
: a_(a_)
{
}
const std::string& a_;
};
with gcc -Wall you don't get a warning.
Why is this legal code?
In the Android open-source qemu code I ran across this line of code:
machine->max_cpus = machine->max_cpus ?: 1; /* Default to UP */
It this just a confusing way of saying:
if (machine->max_cpus) {
; //do nothing
} else {
machine->max_cpus = 1;
}
If so, wouldn't it be clearer as:
if (machine->max_cpus == 0) machine->max_cpus = 1;
Interestingly, this compiles and works fine with gcc, but doesn't compile on http://www.comeaucomputing.com/tryitout/ .