A shared memory is nothing but a piece of memory shared across multiple process.
Feb 22, 2012
Jan 9, 2012
Dec 26, 2011
git tutorial. Use git locally or with Dropbox
I have been working on a project for which I need to restore to different state of the project. I searched and I got an elegant solution.
Oct 30, 2011
A problem; what is the difference between signed and unsigned ?
I was looking at the disassembled code of 2 programs compiled with gcc. In one program I initialised an unsigned variable and in the next program I initialised the same variable as signed.
Oct 27, 2011
Static and Shared libraries with C
This post explains how to use static and shared libraries with C. My platform is gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5).
Oct 12, 2011
Install basic required applications in Ubuntu 10.04 LTS - Lucid Lynx
LTS means long term support. So this version of Ubuntu is a nice flavor. But the main problem with open source OS is it will be just an OS without the some good applications.
Aug 27, 2011
C programs and Makefile, sources, objects, libraries!!?
If we have a number of C sources and header files then how to create an executable from all these. This post is a template for that concept. This post contains a Makefile which is a simple but standard makefile which can be used as a template. I thought of writting this when I started working on embedded programs with C.This post not explains shared library concept.
Take the simplest case, a single main.c file.
#include <stdio.h>
int main ( void )
{
printf("This is a test\n");
return 0;
}
compile it: $gcc -o main main.c
$./main will print the result.
Consider another situation where we have functions defined in different files/directories. Then how to compile to create an executable. Here comes -c, -o options and object file concepts.
I am not writting any explenation for this. Create the following files in a directory and experiment.
Consider we have three functions and a header file another.c define.h functions.c main.c
Take the simplest case, a single main.c file.
#include <stdio.h>
int main ( void )
{
printf("This is a test\n");
return 0;
}
compile it: $gcc -o main main.c
$./main will print the result.
Consider another situation where we have functions defined in different files/directories. Then how to compile to create an executable. Here comes -c, -o options and object file concepts.
I am not writting any explenation for this. Create the following files in a directory and experiment.
Consider we have three functions and a header file another.c define.h functions.c main.c
main.c
--------
#include <stdio.h>
int main ( void )
{
printf ( "%s\n", "This is a printf from main function" );
function_one();
return 0;
}
functions.c
--------------
#include <stdio.h>
#include <define.h>
void function_one ( void )
{
printf("function_one has been executed. The defnition is: %d\n", NUMBER );
another_fun();
}
void function_two ( void )
{
printf("function_two has been executed.\n");
}
another.c
-----------
#include <stdio.h>
void another_fun ( void )
{
printf ( "Another function\n" );
}
define.h
-----------
#define NUMBER 142
Makefile
-----------
CC := gcc
OBJECTS := functions.o main.o another.o
INC1 := ./
INCLUDES := -I$(INC1)
bin: $(OBJECTS)
$(CC) $(OBJECTS) -o bin
functions.o: functions.c
$(CC) $(INCLUDES) -c functions.c -o functions.o
main.o: main.c
$(CC) -c main.c -o main.o
another.o: another.c
$(CC) -c another.c -o another.o
clean:
rm -rf bin *.o
Subscribe to:
Posts (Atom)
For Web Developer
open -a "Google Chrome" --args --disable-web-security
-
Square of 104 ( faster way.. ) Answer will have _ _ _ _ _ .That is five digits . add the 4 to the entire number that is 104+4 ...
-
So start an emulator with sdcard some things that I tried ----> emulator -sdcard sdcard1.iso -avd avd_1.5 mksdcard 8M sdcard emulator -sd...
-
I was thinking about designing a web application which can be used as a profile of us. A profile page which describe ourselves. What I had ...