The following code (a function prototype):
void parse_ini(FSFILE *fp, void(*secFunc)(char*), void(*varFunc)(char*, char*));
presents errors when compiled:
util\setup.c:38: error: syntax error before '*' token
util\setup.c:38: error: 'parse_ini' declared as function returning a function
util\setup.c:38: error: syntax error before 'void'
util\setup.c:50: error: syntax error before '*' token
What is causing this? Using MPLAB C30, which is a version of GCC v3.23 for PIC24F/dsPIC 16-bit microcontrollers.
I'd guess that you haven't included a header that declares/defines FSFILE.
try this
typedef void (*varfuncptr)(char *, char*);
typedef void (*secfuncptr)(char *);
void parse_ini(FSFILE *fp, secfuncptr *secFunc, varfuncptr *varFunc);
Related
I'm getting this error that goes beyond my knowledge :
Error[Pe147]: declaration is incompatible with "__interwork __softfp char *Get_Language_String(enum Lang_Index, enum String_Index)" (declared at line 26 of "E:\Freescale\Freescale_MQX_4_0\demo\ E:\Freescale\Freescale_MQX_4_0\demo\DialogD13_Demo_v5\Strings.c 79
DialogD13_Demo_v5\Strings.h")
I have this in my code :
strings.h:
extern char *Get_Language_String(enum Lang_Index Lang_Ind, enum String_Index Str_Ind);
strings.c:
char *Get_Language_String(enum Lang_Index Lang_Ind, enum String_Index Str_Ind)
{
return languages[Lang_Ind][Str_Ind];
}
What is wrong ?
Thanks in advance,
regards,
Bul.
thanks for response...
It was order of definitions that caused this error.
extern clause in strngs.h was before definitions of enums...
Regards,
Bulek.
I'm trying to compile a program that includes liboss's file, but when I compile I get the following error.
In file included from test.c:1:
/opt/local/include/liboss/soundcard.h:342: error: static declaration of ‘ioctl’ follows non-static declaration
/usr/include/sys/ioctl.h:97: error: previous declaration of ‘ioctl’ was here
/opt/local/include/liboss/soundcard.h:353: error: static declaration of ‘open’ follows non-static declaration
/usr/include/sys/fcntl.h:464: error: previous declaration of ‘open’ was here
/opt/local/include/liboss/soundcard.h:363: error: static declaration of ‘close’ follows non-static declaration
/usr/include/unistd.h:476: error: previous declaration of ‘close’ was here
/opt/local/include/liboss/soundcard.h:366: error: conflicting types for ‘write’
/usr/include/unistd.h:535: error: previous declaration of ‘write’ was here
The line where the first error occurs is this one.
# soundcard.h
static inline int LIBOSS_IOCTL (int x, unsigned long y,...)
{
int result;
va_list l;
va_start(l,y);
result = liboss_ioctl(x,y,l);
va_end (l);
return result;
}
# ioctl.h
__BEGIN_DECLS
int ioctl(int, unsigned long, ...);
__END_DECLS
Is there any way in which I can monkey-patch soundcard.h so that this won't be an issue?
Thnx! A.
Specs: Mac OSX 10.7.4, gcc i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1
It sounds like liboss is trying to provide an oss-compatible soundcard interface on a system where that's non-native by redefining the ioctl function to provide the OSS ioctl operations without the kernel having support for them. If this is the case, you need to make sure sys/ioctl.h (or any header that might include it) does not get included in the same source files that use soundcard.h.
Just add static to /usr/include/sys/ioctl.h:97, /usr/include/sys/fcntl.h:464, /usr/include/unistd.h:476 and /usr/include/unistd.h:535 (and undo those changes again after compilation).
In /opt/local/include/liboss/soundcard.h:366 replace int by ssize_t.
# add static
sudo nano +97 /usr/include/sys/ioctl.h
- int ioctl(int, unsigned long, ...);
+ static int ioctl(int, unsigned long, ...);
# replace int by ssize_t
sudo nano +366 /opt/local/include/liboss/soundcard.h
- static inline int LIBOSS_WRITE (int x, const void *y, size_t l)
+ static inline ssize_t LIBOSS_WRITE (int x, const void *y, size_t l)
I am trying to extend Ruby with a C extension in order to add an event hook.
Unfortunately, I get the following error:
timber.c:7: error: expected ‘)’ before ‘event’
timber.c: In function ‘timber_init_event_hook’:
timber.c:15: error: ‘timber_trap’ undeclared (first use in this function)
timber.c:15: error: (Each undeclared identifier is reported only once
timber.c:15: error: for each function it appears in.)
timber.c: At top level:
timber.c:21: error: expected ‘)’ before ‘event’
make: *** [timber.o] Error 1
The code I have written:
#include <ruby.h>
#include </Users/paulengel/.rvm/src/ruby-1.9.2-p180/node.h> // #include <node.h> raises `error: node.h: No such file or directory`
// Declarations
static void timber_init_event_hook();
static void timber_trap(rb_event_t event, NODE *node, VALUE self, ID mid, VALUE klass);
VALUE timber_start(VALUE self);
void Init_timber();
// Definitions
static void timber_init_event_hook() {
#if defined(RB_EVENT_HOOKS_HAVE_CALLBACK_DATA) || defined(RUBY_EVENT_VM)
rb_add_event_hook(timber_trap, RUBY_EVENT_CALL | RUBY_EVENT_RETURN | RUBY_EVENT_C_CALL | RUBY_EVENT_C_RETURN, 0);
#else
rb_add_event_hook(timber_trap, RUBY_EVENT_CALL | RUBY_EVENT_RETURN | RUBY_EVENT_C_CALL | RUBY_EVENT_C_RETURN);
#endif
}
static void timber_trap(rb_event_t event, NODE *node, VALUE self, ID mid, VALUE klass) {
rb_funcall(rb_mKernel, rb_intern("puts"), 1, rb_str_new2(event));
}
VALUE timber_start(VALUE self) {
// Do something
}
void Init_timber() {
VALUE mTimber = rb_define_module("Timber");
timber_init_event_hook();
rb_define_singleton_method(mTimber, "start", timber_start, 0);
}
Can someone help me out solving this problem? Thanks in advance.
EDIT: Try naming your rb_event_t something other than event. Even though I'm almost positive it's not a C keyword, the compile error you're getting seems to be consistent with that type of problem.
EDIT EDIT: Apparently not the actual problem, but it definitely looks like the error is on those two lines.
In a header file
extern void Trace_Communication(communicationBlock_t mdbMessage);
gives error: expected ‘)’ before ‘mdbMessage’
I am sure that communicationBlock_t is in scope (and reliaze that it would be more efficient to pass a pointer)
If I copy the declaration of communicationBlock_t just before the extern offending line, the error is
error: conflicting types for ‘communicationBlock_t’
note: previous declaration of ‘communicationBlock_t’ was here
Which seems to imply that the offending line has access to the declaration of communicationBlock_t
I guess that I am overlooking something trivial and obvious, but I have been coding all night and can no longer think straight ...
What am I doing wrong? Thanks 1 ,000,000
Update: my guess is that it's an include file tangle ...
typedef struct
{
communicationMessage_t message;
uint8_t length;
#ifdef TESTING
char commandName[32]; // for testing porpoises
DoRunTimeChecks runTimeCheckCallback;
#endif
} communicationBlock_t;
Looks to me like you're using a variable as a type name. What does the declaration of communicationBlock_t look like?
Sorry, folks. It was, as I suspected a deady embrace in #include files
I have a C header file which defines the following function:
void my_func(pthread_t tid);
This is defined by another function:
void my_func(pthread_t tid) {
...
When I compile, it says:
****.h:2: error: expected specifier-qualifier-list before ‘pthread_t’
Any ideas what I'm doing wrong?
You need to #include <pthread.h> in the header file so that pthread_t is in scope for the my_func() prototype.
Without the #include the compiler does not recognize pthread_t as a type, but it needs a type before the argument.
The error expected specifier-qualifier-list before ‘pthread_t’ is saying just that. You need a type (specifier-qualifier-list) before a parameter (‘pthread_t’).