GNU gcc 4.3 partially supports the upcoming c++0x standard: among the implemented features the rvalue reference. By means of the rvalue reference it should be possible to move a non-copyable object or return it from a function.
Are std::streams already movable by means of rvalue reference or does the current library implementation lack...
This very simple code gives me tons of errors:
#include <iostream>
#include <string>
int main() {
std::string test = " ";
std::cout << test;
}
I tried to compile it on linux by typing gcc -o simpletest simpletest.cpp on the console. I can't see why it isn't working. What is happening?
...
I have some code that looks like:
template<unsigned int A, unsigned int B>
int foo() {
int v = 1;
const int x = A - B;
if (x > 0) {
v = v << x;
}
bar(v);
}
gcc will complain about x being negative for certain instantiations of A, B; however, I do perform a check to make sure it is non-negative. What's the best way arou...
On the MSVC++ compiler, one can use the __int8, __int16, __int32 and similar types for integers with specific sizes. This is extremely useful for applications which need to work with low-level data structures like custom file formats, hardware control data structures and the like.
Is there a similar equivalent I can use on the GCC compi...
If I do this:
// In header
class Foo {
void foo(bar*);
};
// In cpp
void Foo::foo(bar* const pBar) {
//Stuff
}
The compiler does not complain that the signatures for Foo::foo do not match. However if I had:
void foo(const bar*); //In header
void Foo::foo(bar*) {} //In cpp
The code will fail to compile.
What is going on?
I'm usin...
If I have a function that returns an object, but this return value is never used by the caller, will the compiler optimize away the copy? (Possibly an always/sometimes/never answer.)
Elementary example:ReturnValue MyClass::FunctionThatAltersMembersAndNeverFails()
{
//Do stuff to members of MyClass that never fails
return success...
There seem to be 3 ways of telling GCC to weak link a symbol:
__attribute__((weak_import))
__attribute__((weak))
#pragma weak symbol_name
None of these work for me:
#pragma weak asdf
extern void asdf(void) __attribute__((weak_import, weak));
...
{
if(asdf != NULL) asdf();
}
I always get a link error like this:
Undefined symbo...
I'm trying to use GDB to debug (to find an annoying segfault). When I run:
gdb ./filename
from the command line, I get the following error:
This GDB was configured as "i686-pc-linux-
gnu"..."/path/exec": not in executable
format: File format not recognized
When I execute:
file /path/executable/
I get the following info:
ELF ...
I need to get the values in the registers with GCC.
Something similar to this:
EAX=00000002 EBX=00000001 ECX=00000005 EDX=BFFC94C0
ESI=8184C544 EDI=00000000 EBP=0063FF78 ESP=0063FE3C
CF=0 SF=0 ZF=0 OF=0
Getting the 32-bit registers is easy enough, but I'm not sure what the simplest way to get the flags is.
In the examples ...
Suppose I have code like this:
template<class T, T initial_t> class Bar {
// something
}
And then try to use it like this:
Bar<Foo*, NULL> foo_and_bar_whatever_it_means_;
GCC bails out with error (on the above line):
could not convert template argument
'0' to 'Foo*'
I found this thread: http://gcc.gnu.org/ml/gcc-help/2007...
This has just come up as a question where I worked so I did a little digging and the answer is a ExpertsExchange one. So I hand you over to the original question asker, Manchung:
I have a project written in pure C which is to be used in embedded system. So, I use pure C to minimize the code size.
When I compile the project, I us...
Hi,
I am forking a number of processes and I want to measure how long those it take to to complete the whole task, that is when all processes forked are completed. Please advise how to make the parent process to wait until all child process are terminated? I want tu make sure that I stop the time watch in the right moment.
Here is as a...
I'm writing a C++ program that doesn't work (I get a segmentation fault) when I compile it with optimizations (options -O1, -O2, -O3, etc.), but it works just fine when I compile it without optimizations.
Is there any chance that the error is in my code? or should I assume that this is a bug in GCC?
My GCC version is 3.4.6.
Is there a...
I'm currently working on some logging code that supposed to - among other things - print information about the calling function. This should be relatively easy, standard C++ has a type_info class. This contains the name of the typeid'd class/function/etc. but it's mangled. It's not very usefull. I.e. typeid(std::vector).name() returns "S...
I just read this post about why new-line warnings exist, but to be honest my team has people working on several different platforms and with several different editors (everyone uses what bests suites them), so the warning has become ubiquitous, and since its not really a warning worth taking care of it's become Noise and makes finding se...
If you have a particular line of C code in mind to examine in the machine output, how would you locate it in objdump output. Here is an example
if (cond)
foo;
bar();
and I want to see if bar was inlined as I'd like.
Or would you use some alternative tool instead of objdump?
...
Is it possible to use the __unused attribute macro on Objective-C object method parameters? I've tried placing it in various positions around the parameter declaration but it either causes a compilation error or seems to be ignored (i.e., the compiler still generates unused parameter warnings when compiling with -Wall -Wextra).
Has anyo...
This is the compiler message (somewhat stripped):
/usr/include/sys/mman.h:145: error: 'mode_t' has not been declared
Another error:
In file included from /usr/include/sys/resource.h:25,
from /usr/include/sys/wait.h:32,
/usr/include/bits/resource.h:172: error: field 'ru_utime' has incomplete type
/usr/include/bits/res...
Suppose I have #define foo in various header files. It may expand to some different things. I would like to know (when compiling a .cc file) when a #define is encountered, to what it will expand, it which file it is and where it got included from.
Is it possible? If not, are there any partial solutions that may help?
Feel free to add c...
For a school assignment I have to write x86 assembly code, except I can't use gcc to compile it since my computer is an x64 machine, and gcc is only excpecting x86 code. Is there a command that'll make gcc accept it x86 assembly code? Thanks
P.S. I know my code is valid since it compiles just fine on x86 machines.
...