C is a general-purpose computer programming language used for operating systems, games and other high performance work and is clearly distinct from C++. It was developed in 1972 by Dennis Ritchie for use with the Unix operating system.

learn more… | top users | synonyms

7
votes
2answers
132 views

Make GNU indent break long comments

Is there a way to convince GNU indent to break long comment and change it to multiline comment? Something like this: // Very long comment, longer than 80 characters. Just imagine that. To this: /* ...
2
votes
1answer
61 views

Is the (Free)BSD Codebase ANSI Compliant?

Google does not seem to shed any light on this topic - But the question is quite simple: Is the FreeBSD (Or any BSD) CodeBase ANSI (c89) Compliant, or does it use c99, c11 or non-standard features ...
2
votes
2answers
35 views

“make” doesn't find an installed library

I am attempting to use make to compile purple-facebook, a plugin for pidgin. It requires json-glib, which I have installed, but whenever I attempt to compile, it returns fatal error: json-glib/json-...
0
votes
1answer
30 views

openpty returning zero as master file descriptor

I am opening a pseudoterminal with openpty function. This will be used to redirect some data coming from a serial port into an external application (in this case, a GPS receiver). The fact is that ...
0
votes
1answer
12 views

How authentication is done between two nodes in tcp/ip or udp client server socket

I have a client socket program and server socket program in C TCP/IP . I execute the server program first on a port say 5000 and then executes client program on the same port and then server respond ...
0
votes
0answers
7 views

How does the native_cpuid() x86 function set the Extended Processor Info and Feature Bits? [closed]

The following function from the Linux kernel is a C implementation for utilizing the CPUID call in ASM. static inline void native_cpuid(unsigned int *eax, unsigned int *ebx, ...
6
votes
5answers
19k views

How do I kill all a user's processes using their UID

I want to kill all running processes of a particular user from either a shell script or native code on a linux system. Do I have to read the /proc directory and look for these? Any ideas? Is there a ...
0
votes
0answers
8 views

Process Family Tree: list_for_each() [migrated]

I'm reading about Process Management in Robert Love's Linux Kernel Development. He's writing about how one can use the following code to iterate over a process's children struct task_struct *...
11
votes
3answers
9k views

How can I find a memory leak of a running process?

Is there a way, I can find the memory leak of a running process? I can use Valgrind for finding memory leaks before the start of a process. I can use GDB to attach it to a running process. How could I ...
6
votes
2answers
3k views

what device name should I have to give in snd_pcm_open other than “default”

I want to record sound from 2 devices simultaneously: internal mic external usb webcam mic Using pulseaudio sound controller, I set either of these devices as default and could record sound with ...
-2
votes
0answers
30 views

convert the input from c program using command line [migrated]

I have written the following c code on emacs that can take line inputs from shell and output that on shell. #include <stdio.h> static char string[200]; int main(){ printf("...
3
votes
0answers
114 views

How can I run 'ls' with options from a C program? [migrated]

I want to execute the command ls -a using execv() on a Linux machine as follows: char *const ptr={"/bin/sh","-c","ls","-a" ,NULL}; execv("/bin/sh",ptr); However, this command does not list hidden ...
1
vote
3answers
8k views

/usr/ucb/cc: language optional software package not installed

I tried to compile some C code to get object file from a shell prompt: $cc a.c But this gives me the following error: /usr/ucb/cc: language optional software package not installed How can I ...
3
votes
1answer
1k views

ioctl: invalid argument for HDIO_GET_IDENTITY

I wrote a program to get the details of hard disk drive using HDIO_ ioctl calls. For writing program, I'm referring Documentation/ioctl/hdio.txt in kernel source(2.6.32). Here is my main part of ...
0
votes
1answer
31 views

Command that indents lines of a C source file

I need a way to auto-indent blocks on a C source file within the terminal. According to the norms. Before: int main() { puts("Hello world"); } After: int main() { puts("Hello world"); }
0
votes
0answers
13 views

setsockopt IPT_SO_SET_REPLACE flag return error (linux) [migrated]

I try to use setsockopt with the flag IPT_SO_SET_REPLACE but i keep getting the wired error from errno Protocol not available this is my code: #include <stdio.h> #include <stdlib.h> #...
16
votes
2answers
10k views

While there is C++ why most of Linux programs are written in C?

Why most of linux programs are written in C? Why they are not written with C++ which is newer than C?
0
votes
2answers
74 views

parsing using loop and assigning row numbers to file

It is a bit complicated. i have a configuration file. it looks something like this. customer="airtel" model_name=fast programmer_typ_of="dev" Now the 1st column contains all the keys and whatever ...
1
vote
0answers
315 views

libpcap missing

I’m trying to run a C program, but every time I try to run it I get this message: error while loading shared libraries: libpcap.so.0.8: cannot open shared object file: No such file or directory I'...
3
votes
1answer
35 views

Determine the name of the static/dynamic library

Quite often I am using third party snippets of c code that uses a Unix/Linux c library, an example #include <glib.h>, #include <net/if.h>. And they require me to know the specific library ...
1
vote
1answer
57 views

SSL related “undefined reference” on libssh2 and libcurl libs when compiling C on OpenSUSE

I been trying to compile a C software but I'm getting 'undefined reference' over SSL libraries I think. The libraries it mentions are there, actually I compiled them all again: zlib + openssl + ...
2
votes
2answers
134 views

Using gcc compile flags

I am trying to understand how to properly setup gcc to find stuff in my environmental variables. Currently I compiled some code, SDL and I added it to my .bashrc and sourced that .bashrc as well. ...
1
vote
0answers
27 views

can two android devices in different network(3g) comunicate themselves with ssh connection?

I have two rooted android devices with different isp(i use different 3g connection for them) and created a double ssh connection(i can with a public ip server)comunicating both to this server(i have ...
0
votes
0answers
25 views

Strange PFN read from pagemap

I m trying to find the physical page to which a range of virtual addresses are mapped in a piece of C code that I ve written. I m using the /proc/self/pagemap to read the mapping. I ve used the code ...
4
votes
0answers
34 views

Linux application development and signal handling

Currently I am having problems with my users complaining about the termination of my application. Under some (seemingly arbitrary) conditions and desktop environments the app is not terminated and ...
0
votes
0answers
25 views

Compile project with cmake for OpenBSD 5.9

I'm writing a shell and have compiled and run it with Ubuntu. It previously built and ran with OpenBSD 5.9 earlier, but now I get compiler error that I don't understand. $ make [ ...
0
votes
0answers
79 views

Where are the definitions for the prototype declarations in <bsd/stdlib.h>?

I have a C program on Ubuntu 16.04, in which I would like to use arc4random_uniform. typedef unsigned char u_char; #include <bsd/stdlib.h> int main () { return (int) arc4random_uniform(100); } ...
0
votes
1answer
29 views

Checking that $((a * b)) evaluates in my own shell [closed]

POSIX seems to define that a shell should be able to evaluate like a calculator the expression $(( a * b)) where * is a binary operator +, - or *. I programmed such a calculator for my own shell and ...
1
vote
1answer
50 views

How to read from another terminal?

I opened two terminals (/dev/pts/1 and /dev/pts/2) and started my application from /dev/pts/1. I want to read in real time from /dev/pts/2 but my code doesn't work: actually some of the symbols are ...
5
votes
2answers
19k views

Default stack size for pthreads

As I understand, the default stack size for a pthread on Linux is 16K. I am getting strange results on my 64-bit Ubuntu install. $ ulimit -s 8192 Also pthread_attr_init(&attr); ...
0
votes
1answer
37 views

Can all of fork(), exec() and system() be wrong? [closed]

I understand why it could be less than best practice if I write C code that executes shell commands by calling system() and that it's better to use exec and fork but then a very experienced C ...
217
votes
4answers
77k views

Why is FreeBSD deprecating GCC in favor of Clang/LLVM?

So I was surfing the net and stumbled upon this article. It basically states that FreeBSD, starting from Version 10 and above will deprecate GCC in favor of Clang/LLVM. From what I have seen around ...
1
vote
1answer
118 views

Using Named Pipes in Bash created in a C Program

I have a C code that takes a rather large input. At every iteration, it processes a small chunk of it and it should send that processed chunk to S3 using curl. In the end, it will generate a number of ...
3
votes
3answers
212 views

POSIX compliance of the cd program?

Is globbing and shell expansion same thing? I'm learning C by writing a custom shell and I'm also learning POSIX. Now I wonder if it is POSIX compliance that cd - takes you back and that ~ means home ...
2
votes
2answers
105 views

How can I find out what linker flags are needed to use a given C library function?

Running example C code is a painful exercise unless it comes with a makefile. I often find myself with a C file containing code that supposedly does something very cool, but for which a first basic ...
1
vote
2answers
49 views

How to extract a function from file? [closed]

I am looking for a command to extract a C function from my code. It would be something like: $ grep -func "MyFunction" foo.c int MyFunction(int i) { return i+1; } I know we can extract it with ...
0
votes
0answers
49 views

Build location-independent GCC binaries

I have some problems with GCC. I want a portable version of GCC because the PC I use for programming cannot be connected to Internet due to some driver issues. So, I read an article on how to compile ...
0
votes
0answers
15 views

Error with libraries after setting up Code::blocks to work as an arduino IDE

First of all I apologize in advance if this is the wrong community, you're welcome to advise me another one to post. I followed this guide: http://arduinodev.com/guide-to-arduino-development-...
0
votes
0answers
14 views

Error occured with USB modem

I have MPC8309 Tower Board and connected USB Modem to it and then established Async PPP on Modem, now I started applying ping from different terminal from my laptop by applying nat commands and ...
0
votes
1answer
90 views

Maintaining single binary across Debian distributions

We are currently migrating our system from Debian 6 to 8. The agenda is to try to maintain single binary across OS platforms (x86 based) However, I tried running a Debian 8–compiled binary in ...
1
vote
1answer
80 views

What is the number at the top for the results for ls -l? [duplicate]

When you type in ls -l, there is a number on the first line labeled "total 22037"? What does this number mean? I am attempting to write my own version of ls -l( in C), and how do I get this value or ...
0
votes
1answer
21 views

Busy /dev/gpio. I can shared it?

I need shared one device between two C applications. This device is a buzzer. I've try open this with O_NONBLOCK flag, but result is same: device or resource busy. Is there any possibility to use the ...
1
vote
1answer
102 views

Why do the Linux kernel headers contain references to nonexistent headers?

I'm trying to build IBCS (source here) on Ubuntu 15.10 (Linux 4.2.35). This module is obviously pretty old, because its CONFIG.i386 file gives gcc an option -m486, which doesn't exist anymore, but ...
0
votes
0answers
40 views

How to call a device's power management methods in another way than during suspend to ram?

Let us consider the e1000e driver for an Ethernet card. This driver provide two power management methods .suspend and .resume to respectively turn off and turn on the card. Those methods are naturally ...
2
votes
1answer
104 views

pkg-config output not working with makefile?

I'm trying to run the makefile, shown in this repo, which is a simple Wayland client. But when I run make, it seems that the output of $(WAYLAND) is blank, and it fails to compile due to not being ...
3
votes
1answer
56 views

No stdlib in UNIX v7?

Browsing through the v7 UNIX Sources I noticed there is no "stdlib" directory - further more using a v7 UNIX Emulator, there is no such file as <stdlib.h>. However functions like exit() and ...
0
votes
1answer
186 views

how to define the top dir in automake system?

I usually use a typical steps to generate the makefile, and firstly I use the "build.sh init" to generate the configure file, and then I use "configure" to generate the makefile with makefile.am file. ...
1
vote
0answers
26 views

Unable to establish PPP on USB dongle?

I have USB Dongle and i am willing to setup ppp through the dongle. I have done following steps to setup ppp. 1.When i plugged the dongle into Ubuntu 14.04. It has been detected as the Mass ...
2
votes
1answer
50 views

non-reentrant libraries in shared memory?

I found this Q&A saying shared libraries can be shared between processes using shared memory. It seems like it would be impossible, though, to share code between processes without some pretty ...
1
vote
0answers
31 views

I2C Read unexplained data [closed]

I am trying to communicate with a PHY device using I2C primitives (read()/write()) in C language in user space. And i am getting some unexplained output in my program. First, the bus number is 2 and ...