I have a static library file called libunp.a, I do know I could use gcc -lunp xx to link to the library.
I could use #pragma comment(lib,"xxx.lib") to tell the microsoft c/c++ compiler to include the library,how could I do it under linux/gcc?
thanks.
...
Hello,
I am trying to use a message queue for communication between two unrelated processes in Linux. I am aware that using a common key value will allow us to open the same message queue in both the unrelated processes. But the problem is that at times a key value corresponding to a message queue might already be used by some system ut...
Is it possible to create binaries of other platform on Linux? Say I have a program that can be compiled using gcc to .o file but can we use it to output exe that can be run on windows ?
...
Here the code
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <netinet/in.h>
#include <resolv.h>
int main (int argc, char *argv[])
{
u_char nsbuf[4096];
char dispbuf[4096];
ns_msg msg;
ns_rr rr;
int i, j, l;
if (argc < 2) {
printf ("Usage: %s <domain>[...]\n", argv[0]);
exit ...
I know that if I am inside some fuction foo() which is called somewhere from bar() function, then this return address is pushed on stack.
#include <stdio.h>
void foo()
{
unsigned int x;
printf("inside foo %x \n", &x );
}
int main()
{
foo();
printf("in main\n")...
In errno.h, this variable is declared as extern int errno; so my question is, is it safe to check errno value after some calls or use perror() in multi-threaded code. Is this a thread safe variable? If not, then whats the alternative ?
I am using linux with gcc on x86 architecture.
...
I have a piece of C code that looks like this:
const char (*foo)[2] = bar();
Now bar() is a function that returns a (const void *). How do I properly cast this const pointer? The code produces this warning from GCC : "initialization discards qualifiers from pointer target type". Here are some of my unsuccessful attempts:
const char (...
I cut&pasted the below code from a previous question into a file called "avishay.cpp" and then ran
gcc avishay.cpp
only to get the following error messages from the linker. What went wrong, what should I have done?
carl@carl-ubuntu:~/Projects/StackOverflow$ gcc -static avishay.cpp
/tmp/cccRNW34.o: In function `__static_initializati...
I'm using gcc for my c programmes. How can I check which method is faster (suppose that I write a code to swap two numbers and I rewrote the same code using bit operator), is there any tool in linux to check the time,performance and space?
...
I have once heard a saying,we could live without linux,but we definitely could not live without gcc.It seems there is only one c compiler in the Linux world.Is there any alternatives to gcc and does programmers under AIX/HPUX/Solaris use gcc to develop programs?
thanks.
...
G'day,
on a 64bit RHEL5 box we need to install our 32bit application. For some reasons we need to use gcc 4.0.3 for this, so I tried to install that version on the target machine first, like I did a thousand times on 32bit target platforms.
This time, however, I am experiencing problems. I have bootstrapped and instaled gcc 4.0.3 into...
We can get the type returned by function in gcc using the typeof operator as follows:
typeof(container.begin()) i;
Is it possible to do something similar for functions taking some arguments, but not giving them? E.g. when we have function:
MyType foo(int, char, bool, int);
I want to retrieve this "MyType" (probably using typeof ope...
Hi, I'm trying to build a project I have and it has several exported functions. The functions follow the stdcall convention and they get mangled if compiled with GCC as
Func@X
Other compilers mangle the name like this:
_Func@X
Is any way I can force GCC to mangle the names of the exported functions to the later example?
...
I am working on auto vectorization with GCC. I am not in a position to use intrinsics or attributes due to customer requirement. (I cannot get user input to support vectorization)
If the alignment information of the array that can be vectorized is unknown, GCC invokes a pass for 'loop versioning'. Loop versioning will be performed when ...
I have the following warning:
"controlling expression is constant"
because of assert statement like this:
assert(... && "error message");
how can I suppress warning from this particular line?
The compiler I use is NVIDIA cuda compiler.
I think it is llvm based.
okay, it may not be llvm, as the pragma's do not have any affect.
The B...
I've a small C-program which just reads numbers from stdin, one at each loop cycle. If the user inputs some NaN, an error should be printed to the console and the input prompt should return again. On input of "0", the loop should end and the number of given positive/negative values should be printed to the console. Here's the program:
#...
If compiling and linking with MinGW gcc v3 is painfully slow, and gcc v4 is not the default install option: What, for a beginner are the advantages/disadvantages of installing one version or another?
Say for example with gcc v4, I want to use PDCurses or other GNU libraries will I first have to recompile these from source?
I'm only a...
Hi everyone,
I'd like to compile my application for version 10.5 and forward. Ever since I upgraded to Snow Leopard and installed the latest XCode, gcc defaults to 10.6. I've tried -isysroot /Developer/SDKs/MacOSX10.5.sdk but that doesn't seem to work. Is there a GCC flag that allows me to set the SDK?
(Incidentally, I changed the gcc ...
While compiling my program which is using libevent library I am using gcc option -levent. But I am getting this error -
/usr/bin/ld: cannot find -levent
I do not have libevent on my system so I am statically linking to it while compiling using
gcc -o Hello -static -I libevent-1.4.12-stable/ hello.c -levent
How can i resolve this?
...
hi there,
for the sake of simplicity ill just paste an example instead of my entire code which is a bit huge. while im porting my code to VC++ instead of using GCC i need to rewrite a few inline assembly functions that receive pointers and save values on those pointers.
imagine cpuid for example:
void cpuid( int* peax, int* pebx, int* ...