I have written a program with several include files. The main program has some assembly code and for that I have used src directive. I assembled the main program which created the .src extension and then replaced the original C file with the .src. file. I also included the library file C51C.lib in the project and then build the project. The Project is successfully compiling but the hex file is too small compared to similar programs that I have written before. This is the how I included the other .C files in my program.
#pragma src #include <stdio.h> #include <intrins.h> #include <string.h> #include <ctype.h> #include <process.h> #include "keyboard.h" #include "34init.c" #include "map.c" #include "master.c" #include "voltage.c" #include "receive.c" #include "transmit.c" #include "alarm.c"
Does the program work on the target? Stefan
You say your hex file is "too small" --- to small for what? Absolute size of a .hex file is hardly every a useful criterion to judge by.
Some comments can make life difficult The problem has been solved now. When compiling the file, it had given an error that there is an unterminated comment at the end of the main C file. I added the comment ending " */ " and the it successfully compiled. (Note: The color of the code didn't change as it does when some line gets commented which was very confusing. I couldn't figure out what I was commenting ) It was then that I saw the hex file generated was too small. I was expecting a hex file of around 100kb+ and I was getting a hex file of only 2kb. I then added the directive "list include files" and in the .lst file created I saw that only till the include file "map.c", were the include files being included. After carefully going through "map.c" I saw that in the end of "map.c" there was the beginning of a comment "/*" and that is why I was getting a compilation error initially and when I corrected the compilation error by adding "*/" in the end of the main C file, everything after "map.c" was commented which included the main C file and all the included files thereafter. So from now on, no more "/*" and "*/" method of commenting blocks for me. I will stick to the more normal "//" style of commenting lines. The actual hex file now generated is 109kb. Thanks for your advice. Happy Programming. Abhisek Sanyal abhisek_san1@yahoo.co.in
I'd have thought it was pretty obvious that adding a closing comment at the end of your source code to rectify an 'unterminated comment' error wasn't a very good idea. Another thing that isn't a very good idea is using #include with .c files. You should create a project and add the files to the project instead. Stefan