Wednesday, August 29, 2012

Difference between UDS and kwp2000


http://automotiveconceptsblog.wordpress.com/2012/06/06/kwp2000-and-uds-difference/

Tuesday, August 14, 2012

Wednesday, July 25, 2012

Little and BIG Endian




# include <stdio.h>
void main()
{
unsigned char test=0x01;
test=test<<1;
if(test)
{
     printf("This processor is little Endian");
}
else
{
    printf("This processor is Big Endian\n");
}
}
for more details visit
http://people.cs.umass.edu/~verts/cs32/endian.html

Sunday, May 13, 2012

About extern and static

About Extern and static .


Extern is the keyword give the linkage to another file to use the same variable .

Where as static is the keyword limit the linkage to internal . If we used the function name begin with static the scope of the variable is limited to internal.


#include <stdio.h>

int bar=34;

int main()

{

barTest();

printf("\n Bar in main---%d", bar);

return 0;

}// main file name is static1.c


#include <stdio.h>

extern int bar;

void barTest()

{

printf("\n Bar in barTest---%d", bar);

}// add.c subfile


output will be

Bar in barTest---34

Bar in main---34



Now change the program little bit


#include <stdio.h>

int bar=34;// changed

int main()

{

barTest();

printf("\n Bar in main---%d", bar);

return 0;

}// main file name is static1.c


#include <stdio.h>

static int bar=90;// changed hear

void barTest()

{

printf("\n Bar in barTest---%d", bar);

}// add.c subfile


output will be

Bar in barTest---90

Bar in main---34


int bar in add.c is limited to local to that file

now without both static as well as extern

At the time of linkage the this will produce error

Now come to function using static


#include <stdio.h>

int bar=34;

int main()

{

barTest();

printf("\n Bar in main---%d", bar);

return 0;

}// main file name is static1.c


#include <stdio.h>

extern int bar;

static void barTest()

{

printf("\n Bar in barTest---%d", bar);

}// add.c subfile

Now the void barTest is implicit to the file add.c if called from other file .

it will restrict access the compiler will give the error as “undefined reference to barTest”

Diiference between MACRO and CONST ?

Diiference between MACRO and CONST ?

MACRO
1.It is a replaces the test with a value
2.It value can't be altered but it is changed using pre-
processor derivative  #undef  .
3.once it is defined it is can't be localized like  normal value
(same name can't used inside like local)
4.It is preprocessor directive it process all the value before it compile

CONST
1.it stored in ROM. we can using to other files of C using extern
 that is not possible in MACRO.
2. It have address so we can use pointer as well as size of operator
3.It can be localized  in side a function
4. it is optimized by compiler