just a warning of gcc
just a warning of gcc
It is a good ideal to compile the OS kernel with gcc
and nasm
but when I compile my .c file it alwaays return me a warning like this:
warning: no newline at end of file
I have a manual of gcc ,but when I look throught at it ,I can not find anything about the warning !
It is may not so important,because the .o file can be used,but it is so boring !
how can I make it.
and nasm
but when I compile my .c file it alwaays return me a warning like this:
warning: no newline at end of file
I have a manual of gcc ,but when I look throught at it ,I can not find anything about the warning !
It is may not so important,because the .o file can be used,but it is so boring !
how can I make it.
Re:just a warning of gcc
add a new line at the end of the file... Your last line should always be blank, in windows-terms. In other words, you should terminate each line that does contain something with a newline.
If you editor strips off the last newlines get a better editor.
If you editor strips off the last newlines get a better editor.
Re:just a warning of gcc
thanks for your attention ,I have solve this warning !
but now I have a other thing,that I can not understand !
if I creat files as head.h and kernel.c
here is some code in head.h
and in kernel.c I write like this :
and gcc compile the kernel.c,it brings to me a lot of error
but if I write this
unsigned char kkkk=1;
it is ok?
who can explain why "#define byte unsigned char"does not work as I think!or maybe I forget some parameters to gcc
thanks for your help ahead!
but now I have a other thing,that I can not understand !
if I creat files as head.h and kernel.c
here is some code in head.h
Code: Select all
#define byte unsigned char
Code: Select all
#include "head.h"
//something else
byte kkkkk=1;
//others
but if I write this
unsigned char kkkk=1;
it is ok?
who can explain why "#define byte unsigned char"does not work as I think!or maybe I forget some parameters to gcc
thanks for your help ahead!
Re:just a warning of gcc
It isn't exactly needed - that's why it's a warning, instead of an error.
But imagine:
And:
If your preprocessor isn't smart, you might lose the [tt]#include <bar.h>[/tt] in the comment from [tt]foo.h[/tt]...
Just play it safe, end your files with a newline. Even if all you do it for is to satisfy the compiler. The compiler is your friend, not your enemy.
But imagine:
Code: Select all
// foo.h
void somecode() // no newline at end of this line
Code: Select all
// main.c
#include <foo.h>
#include <bar.h>
Just play it safe, end your files with a newline. Even if all you do it for is to satisfy the compiler. The compiler is your friend, not your enemy.
Every good solution is obvious once you've found it.
Re:just a warning of gcc
you mean typedef like this:
in head.h
typedef unsigned char byte
but it seems like not work !
in head.h
typedef unsigned char byte
but it seems like not work !
Re:just a warning of gcc
Show us the GCC errors in question, and we might be better able to help.
Every good solution is obvious once you've found it.
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:just a warning of gcc
1. you should make sure your header file is processed correctly. It has to be somewhere in the "virtual path" to be seen by GCC.
2. you should have a ";" at the end of your typedef line
3. seeing the error/warning gcc produces would indeed help alot.
2. you should have a ";" at the end of your typedef line
Code: Select all
typedef unsigned char byte;