“clang” is a compiler that supports the compilation of C, C++, and Objective-C source files. It is part of the LLVM (Low-Level Virtual Machine) project and is designed to be a modern and efficient alternative to traditional compilers like GCC (GNU Compiler Collection). The primary purpose of clang is to translate human-readable source code into […]
C
nm : Command to list the symbols in object files.
nm displays the name list (symbol table of nlist structures) of each object file in the argument list. If you want to peep into an object file and see what are the various symbols that are defines in it the command will come handy. It takes an object file as input and lists out all […]
make: Nothing to be done for `default’
Most programs build with a simple, two-command sequence: $ ./configure $ make The configure program is a shell script that is supplied with the source tree. Its job is to analyze the build environment. configure command creates several new files in our source directory. The most important one is Makefile. Makefile is a configuration file […]
printk and console log level
printk() is to the kernel what printf() is to the userspace. Lines written by printk() can be displayed through the dmesg command. Depending on how important the message you need to print is, you can choose between eight log-level messages, defined in include/linux/kern_levels.h, along with their meaning. The syntax of printk is: printk (“log level” […]
How to use execl (example included)
execl is one of the families of exec calls that act as a front end to the execve. The following screenshot refers to man execl: The arguments for these seven exec functions are difficult to remember. The letters in the function names help somewhat. The letter p means that the function takes a filename argument […]
Introduction to Array in C Programming
An array is a collection of similar data elements. These data elements have the same data type. The elements of the array are stored in consecutive memory locations and are referenced by an index (also known as the subscript). If one subscript, then we call a one-dimensional array. Memory representation in an array The array […]
C Programming Basics – Interview Questions
1. What is Token? A token is a building block of a program. A C program consists of various tokens and a token is either a keyword, an identifier, a constant, a string literal, or a symbol. 2. What is Keyword? Keywords are special reserved words associated with some meaning. 3. What is keyword auto […]
Basics of C programming
Structure of C Program A C program is divided into different sections. There are six main sections to a basic c program. The six sections are: Documentation Link Definition Global Declarations Main functions Sub programs The whole code follows this outline. Each code has a similar outline. Now let us learn about each of these […]
Serial Port Programming: tcflush – TCIFLUSH,TCOFLUSH example
termios The termios module provides a POSIX-style interface for controlling the behavior of TTYs and other serial communication devices on UNIX systems. All the functions operate on integer file descriptors such as those returned by the os.open() function or the fileno() method of a file object. In addition, the module relies on a large collection […]
Linux Device Driver example for dump_stack() to print the stack trace of module loading
One of the useful options in debugging is to print the call trace/stack trace. Linux kernel provides a function to print the stack trace: dump_stack(). The dump_stack function produces a stack trace much like panic and oops, but causes no problems and we return to the normal control flow. Calling dump_stack() function will print the […]