just a warning of gcc

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
njmarshal

just a warning of gcc

Post by njmarshal »

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.
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Re:just a warning of gcc

Post by Candy »

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.
Poseidon

Re:just a warning of gcc

Post by Poseidon »

why is a newline at the end of the file actually needed? :)
njmarshal

Re:just a warning of gcc

Post by njmarshal »

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

Code: Select all

#define  byte unsigned char
and in kernel.c I write like this :

Code: Select all

#include "head.h"
//something else

byte   kkkkk=1;
 //others
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!
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re:just a warning of gcc

Post by Solar »

It isn't exactly needed - that's why it's a warning, instead of an error.

But imagine:

Code: Select all

// foo.h

void somecode() // no newline at end of this line
And:

Code: Select all

// main.c

#include <foo.h>
#include <bar.h>
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.
Every good solution is obvious once you've found it.
Curufir

Re:just a warning of gcc

Post by Curufir »

Use typedef not define.
njmarshal

Re:just a warning of gcc

Post by njmarshal »

you mean typedef like this:

in head.h
typedef unsigned char byte

but it seems like not work !
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re:just a warning of gcc

Post by Solar »

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.
User avatar
Pype.Clicker
Member
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

Post by Pype.Clicker »

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

Code: Select all

typedef unsigned char byte;
3. seeing the error/warning gcc produces would indeed help alot.
Post Reply