[cfe-dev] Invalid token error

रजनीश rdogra at earthlink.net
Mon Mar 9 22:11:07 PDT 2009


Shouldn't Clang give a warning of invalid data type (ssize_t)
right now it just gives invalid token error and underline of token is  
not there either.
Caret points to plat_read.  Is that correct?

token.c:4:9: error: invalid token after top level declarator
ssize_t plat_read(int fd, void *buf, size_t count);
         ^

plus there is 'int' that is printed on plat_close warning right below  
caret symbol
which seem to be not needed.

token.c:6:1: warning: type specifier missing, defaults to 'int'
plat_close(int fd)
^
int

=========================================

~/clang-test-> cat token.c
#include <stdio.h>
#include <stdarg.h>

plat_close(int fd);
ssize_t plat_read(int fd, void *buf, size_t count);

plat_close(int fd)
{
   return close (fd);
}

ssize_t plat_read(int fd, void *buf, size_t count)
{

}

=========================================

~/clang-test-> ccc  token.c
token.c:3:1: warning: type specifier missing, defaults to 'int'
plat_close(int fd);
^
int
token.c:4:9: error: invalid token after top level declarator
ssize_t plat_read(int fd, void *buf, size_t count);
         ^
token.c:6:1: warning: type specifier missing, defaults to 'int'
plat_close(int fd)
^
int
token.c:10:9: error: invalid token after top level declarator
ssize_t plat_read(int fd, void *buf, size_t count)
         ^
4 diagnostics generated.

===========================================================
~/clang-test-> gcc -std=c99 token.c
token.c:4: warning: type defaults to ‘int’ in declaration of  
‘plat_close’
token.c:4: warning: data definition has no type or storage class
token.c:5: error: syntax error before ‘plat_read’
token.c:5: warning: type defaults to ‘int’ in declaration of ‘plat_read’
token.c:5: warning: data definition has no type or storage class
token.c:8: warning: return type defaults to ‘int’
token.c: In function ‘plat_close’:
token.c:9: warning: implicit declaration of function ‘close’
token.c: At top level:
token.c:11: error: syntax error before ‘plat_read’
token.c:12: warning: return type defaults to ‘int’





More information about the cfe-dev mailing list