c

Failed to compile with distcc, but OK without it.

Hi guys. I'm trying to compile RaLink drivers for usb wifi dongle. Without using distcc everything is OK but if i use distcc there is error. Here make log: make -C UTIL/ cp -f os/linux/Makefile.6.util /home/tobi/RaLink_driver/UTIL/os/linux/Makefile make -C /home/tobi/linux/ SUBDIRS=/home/tobi/RaLink_driver/UTIL/os/linux modules mkdir -p...

Redefine / resize C array in Objective C?

I have a C array in Objective C defined as follows: id keysArray; Then in an if block, i would like to redefine the array based on a condition: if (somethingIsTrue){ id keysArray[4][3]; } else { id keysArray[6][1]; } Then outside of the if block, when i access the array, i get errors saying the keysArray does not exist. Th...

execv, select and read

Hello, I am creating a child-parent fork() to be able to communicate with a shell(/bin/sh) from the parent through a pipe. The problem is: In a parent I set a select() on a child output, but it unblocks only when the process is finished! So when I run say ps it's okay. but when I run /bin/sh it does not output until shell exits. But I ...

cstring trouble for a beginner

Hi I'm trying to make a program that read a file line by line and then put the readed line into a a linked list, my problem is to add the string to list. Look at the code, in the else test you can see my problem. #include<stdlib.h> #include<stdio.h> struct list_el { char *ord; struct list_el * next; }; typedef struct list_...

Why does this program give segmentation fault?

Hi, It's a beginners question: Why is this breaking/giving an error? #include <stdio.h> #include <stdlib.h> #include <string.h> char *strtrim_right(char *p) { char *end; int len; len = strlen( p); while (*p && len) { end = p + len-1; if(isalpha(*end)) *end =0; else break; } return(p);...

Can macros be used to simulate C++ templated functions?

I have a C program in which I need to create a whole family of functions which have the same signatures and bodies, and differ only in their types. What I would like to do is define a macro which generates all of those functions for me, as otherwise I will spend a long time copying and modifying the original functions. As an example, one...

How to add a C++ compiler flag to extconf.rb

I'm writing a Ruby extension, for which I have a standard mkmf configuration script, but I need to add a special include flag (--std=c++0x) to all of the C++ compilation steps. I don't want it in the C compilation steps, 'cause it throws warnings. How should I do this? require 'mkmf' create_makefile('thing') For instance, I tried $CXX...

K&R interface for reading directories: superfluous DIR structure?

In the 2nd edition of "The C Programming Language" by Kernighan and Ritchie they implement a simplified version of the UNIX command ls (section 8.6 "Example - Listing Directories", p. 179). For this purpose they create the following interface which provides a system-independent access to the name and inode number of the files stored in a...

what does 0 indicate in socket() system call?

hi.. what 0 indicates in following line? what are other flags i can use? server = socket(AF_UNIX, SOCK_STREAM, 0) ...

Compiling C in Windows XP

Hi, I want to learn Vim editor and I'm trying to compile a C file. I've installed MinGW and I've added gcc.exe to System Path: %SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Arquivos de programas\TortoiseSVN\bin;c:\Arquivos de programas\Microsoft SQL Server\100\Tools\Binn\;c:\Arquivos de programas\Microsoft SQL Server\...

Main function's arguments, cant understand this!!!

Why is my code under giving me back "Not a valid command" when i give the argument print ? int main(int argc, char *argv[]) { printf("Argument 2 er %s\n", argv[1]); if(argv[1] == "print") { printf("Print kommando kalt"); } else if(argv[1] == "random") { printf("Random kommando kalt"); } else if(argv[1] ...

How to execute a shell script from C in Linux?

How can I execute a shell script from C in Linux? ...

Bug only appears when running C code inside NetBeans

Running a piece of C code from inside Netbeans 6.8 causes a Segmentation Fault. But the problem doesn't appear when running in debugging mode or from shell. Tried both in external terminal and output window of Netbeans. The process is threaded, and uses an itimer that sends a signal, which I am masking with pthread_sigmask for threads t...

Executing shell script with system() returns 256. What does that mean?

I've written a shell script to soft-restart HAProxy (reverse proxy). Executing the script from the shell works. But I want a daemon to execute the script. That doens't work. system() returns 256. I have no clue what that might mean. #!/bin/sh # save previous state mv /home/haproxy/haproxy.cfg /home/haproxy/haproxy.cfg.old mv /var/run/ha...

Tell whether a text string is an IPv6 address or IPv4 address using standard C sockets API

I have a program where an external component passes me a string which contains an IP address. I then need to turn it into a URI. For IPv4 this is easy; I prepend http:// and append /. However, for IPv6 I need to also surround it in brackets []. Is there a standard sockets API call to determine the address family of the address? ...

Why use FitNesse when the tests are highly technical?

It seems to me FitNesse has the following advantages: Let a non-technical person define sets of test data and expected results (how they define success). A non-technical person could be a user, a product manager, or possibly a software quality professional who does not have access to the source code and/or does not know how to program ...

Recording command line input and output on linux with C

Basically I want to do a program almost like a keylogger. The thing is that I as network admin sometimes I don't remember what I did to a machine on certain case, or same times I make howto's and tutorials for linux. I want to record what have i done. So basically the idea of this program is: you type the name of the program, (I call it...

Why do static libraries end in '.a' c++/c ?

Just doing a little work this morning making some static libraries and wanted to know why static libraries end with '.a'. No one in my office knew so I thought I would ask around on SO. We are writing code in C++/C/Obj-C ...

When do I need to typecast in C?

I understand typecasting...but only in retrospect. My process to figure out what requires typecasting in expressions is usually retroactive because I can't predict when it will be required because I don't know how the compiler steps through them. A somewhat trite example: int8_t x = -50; uint16_t y = 50; int32_t z = x * y; On my 8-b...

Handshake with spoofed IP

I noticed some legit connection is like this: 6221 29.880628 5.4.3.2 1.2.3.4 TCP 61235 > cbt [SYN] Seq=0 Win=8192 Len=0 MSS=1452 SACK_PERM=1 6222 29.880646 1.2.3.4 5.4.3.2 TCP cbt > 61235 [SYN, ACK] Seq=0 Ack=1 Win=16384 Len=0 MSS=1460 SACK_PERM=1 6240 29.984383 5.4.3.2 1.2.3.4 TCP 61235 > cbt [ACK] Seq=1 Ack=1 Win=65340 Len=0 6241...