Using GCC, I am trying to add simple exception logic to this program. Ideally, a simple "if" would work well. IF the fopen succeeds then do x, if it fails do z. Is there a simple way to do this?
#include <stdio.h>
main()
{
FILE *ptr;
ptr = fopen("c:\\RedyBoot.bat","r");
fclose(ptr);
return 0;
}
...
I have a stock mac-mini server (2.53GHz, 4GB, 5400RPM drive) which I use for iphone development. I am working on a smallish app. The compilation seems to be taking longer and longer (now about 20min). The app is about 20 small files totaling 4000 lines. It links to C++/Boost.
What suggestions do you have to speed up the compilation proc...
GCC doesn't seem to approve of instanciating templates with local classes:
template <typename T>
void f(T);
void g()
{
struct s {};
f(s()); // error: no matching function for call to 'f(g()::s)'
}
VC doesn't complain.
How should it be done?
...
Question: Not able to compile a C++ program with gcc compiler.
**oyscs1 /ms/user/a/agrajagr/test/macros 51$ cat info.C**
#include<iostream>
using std::cout;
using std::endl;
int main()
{
#ifdef __cplusplus
cout << "C++ compiler in use and version is " << __cplusplus << endl;
#endif
cout <<"Version is " << __STDC_VERSION__ << endl;
cout ...
I am trying to limit the ABI of a shared library using the gcc's fvisibility feature. However I am confused what is the correct way to do it.
My makefile organizes the build process in two stages. At the first step all .cpp files are built to object files using some gcc options. Then all the object files are linked together using anoth...
I'm currently using GCC, but I discovered Clang recently and I'm pondering switching. There is one deciding factor though - quality (speed, memory footprint, reliability) of binaries it produces - if gcc -O3can produce a binary that runs 1% faster or takes 1% less memory, it's a deal-breaker.
Clang boasts better compile speeds and lower...
I tried to use astyle to format the code base I've to work with. When I use the option --add-brackets the executable is not identical (If I only use -t and/or -b the output is identical).
if(a) return b
is modified to
if(a)
{
return b
}
So my question is. Does gcc generate the same output if I only add and/or delete braces (ob...
Hey,
I'm running the following benchmark:
int main(int argc, char **argv)
{
char *d = malloc(sizeof(char) * 13);
TIME_THIS(func_a(999, d), 99999999);
TIME_THIS(func_b(999, d), 99999999);
return 0;
}
with normal compilation, the results are the same for both functions
% gcc func_overhead.c func_overhead_plus.c -o func_overhead...
We have decide to port our application that currently runs on solaris sparc to linux x86 system. Which compiler, Sun Studio or GNU gcc would be more beneficial to use on linux? Which one would produce at a good level of optimized binaries?
Any help or directions would be appreciated!
Thanks in advance.
...
* glibc detected free(): invalid pointer: 0x41e0ce94 ** ,,,
GCC is running well but ECLIPSE CDT using GCC is thwing this runtiime error ,why ?
...
I'm porting some old C++ project on Linux (RHEL 5.3) and, therefore need to obtain all the binaries on RHEL 5.3.
The result should be in the end several libraries + the executable.
I have some dependencies from several 3rd parties.
My project libraries have dependencies as some of the 3rd party libraries.
My library MyLib depends My3rd...
I have almost the same problem as described here. But I'm linking with release version of boost.
I build it by myself under WindowsXP with gcc-toolset
bjam --build-dir=build-directory
toolset=toolset-name link=shared
variant=release threading=multi
linking as
g++ -enable-auto-import -omain.exe main.o -L"path_to_boost_libdir...
I'm trying to get gcc to work on an Amazon EC2 image of Fedora 8, but I'm running into an issue with the libraries. ld is not finding -lz -lm -lbz2.
I've tried adding -L /lib and -L /usr/lib to the arguments for gcc, but it is still not working.
What am I missing?
...
I'm trying to generate a python wrapper for a C++ library that I am putting together. I have just come across SWIG and am trying to use this in conjunction with distutils. I'm modifying someone elses code, so odd errors were to be expected but this one is just confusing.
I've managed to generate a c++ wrapper file with SWIG and am now a...
I like to compile my code with -Wall, and sometimes even -pedantic. It's partly a style thing, and partly the fact that it does occasionally emit very, very useful warnings (such as using = rather than ==).
However, the writers of some of my headers are clearly not such sticklers. Compiling with either of the two warning levels yields ...
I've built a GCC cross-compiler for arm, and I can prove it works in both trivial cases (Hello World), and in more serious uses (I've successfully cross compiled several libraries, most recently libjpeg).
However, I'm trying to compile a particular file into an object file, which compiles fine using my x86 GCC, but yields the following ...
Im trying to build GLib-2.4.0 using the makefile.
I get this error:
gcc -DHAVE_CONFIG_H -I. -I. -I.. -I.. -DG_LOG_DOMAIN=\"GLib\" -DG_DISABLE_CAST_CHECKS -DG_DISABLE_DEPRECATED -DGLIB_COMPILATION -pthreads -g -O2 -Wall -MT gatomic.lo -MD -MP -MF .deps/gatomic.Tpo -c gatomic.c
-fno-common -DPIC -o .libs/gatomic.o
/var/tmp//cctTs...
Sample code for fmod
#include <stdio.h>
#include <math.h>
int main(void)
{
double x = 0.14527, y = 3.14159;
printf("fmod(x, y) = %.6lf\n", fmod(x, y));
return 0;
}
$ gcc main.c -o main
I get
/tmp/ccztJO01.o: In function `main':
main.c:(.text+0x4d): undefined reference to `fmod'
collect2: ld returned 1 ...
Currently, while compiling a C program which uses pthread library function I have to specify compiler option -lpthread explicitly. Please suggest a way to configure ldconfig so that the pthread library could be used without specifying it on the command line.
presently lpthread -p gives the following output :=
[root@localhost lib]# ldco...
I have access to computer in a public library and I want to try out some C++ and maybe other code. Problem is that there is no g++ installed and I can't install it using packages because I have no root access. Is there a "smart" way to make a full environment for programming in a home folder?
I have gcc installed (I can compile C code)....