View Full Version : A doubt i have been having for a long time..

03-05-2012, 05:25 PM
Guys, i have been using avinash gupta's lcd library (extremeelectronics.co.in) for quite a long time now. now his library is split into .c and .h files. Now why exactly is that done? can all functions and macros not be put in one header file? I have been poring over this question for a while now.

Also on another note, does anyone know of some good tutorials for implementing PID in a line follower. I have gone through most of the google results and formed a rudimentary idea, but still lack a proper understanding.
Thanks :)

03-05-2012, 06:58 PM
A1 . http://en.wikipedia.org/wiki/Header_file
A2. http://www.roboticsindia.com/entry.php/180-PID-From-Theory-To-Implmentation , http://www.roboticsindia.com/content.php/149-Competitions-Robotics-3-The-Build-and-a-Fast-Line-Follower-using-PID

03-05-2012, 09:11 PM
Sorry, if my doubt seemed stupid, but i went through that page for header files and still dont have an understanding(I have no formal introduction to C). If you could elaborate a bit, it would be very helpful.

03-09-2012, 09:09 AM
You(and many other) don't get the point is that you are using C as a toy (kids thing) but its actually a tool (professional thing).

What do you mean by that ?

I mean have you ever written a program that takes 2 days to compile ?

A professional software has thousands of source file (say the Linux Kernel or Open Office).

C Supports a feature called separate compilation and a linker at final stage.

Whats the use of it?

All .c files are first complied to their object file called .o files in gcc arena.

In your approach all modules are kept in .h file which are included in the main program.

Since the compiler always get the pre-processed source file. So in your approrch evey time the compiler will be getting a single preprocced source file made by the preprocessor. And it will be huge say 1500mb and it will take hours to compile !

Even if you changed any of the file, just only a single varriable it will take hours to compile each time.

But in my approach lcd.c will be complied only once to a lcd.o file. Latter on only your application file is compiled.

For a small project like this the speed is NOT obvious but for a large project its very obvious.

It also has many other advantages too. But I don't have time to write them.