unknown type name 'ETSTimer' - c

i've got this error always when i'm using the below code ,
so please could anyone tell me where is my mistake??
the code is:
#ifndef OSAPI_H
#define OSAPI_H
void sdk_os_timer_setfn(ETSTimer *ptimer, ETSTimerFunc *pfunction, void *parg);
void sdk_os_timer_arm(ETSTimer *ptimer, uint32_t milliseconds, bool repeat_flag);
void sdk_os_timer_disarm(ETSTimer *ptimer);
#endif
errors i've got:
1- :4:25: error: unknown type name 'ETSTimer' 2- :4:43: error: unknown
type name 'ETSTimerFunc' 3- :5:23: error: unknown type name 'ETSTimer'
4- :6:26: error: unknown type name 'ETSTimer'
thanks for everyone for the help

Related

X509_NAME macro in C won't compile

This is a silly compilation error, but for the life of me I can't find out what's wrong. I have spent hours on it, but I have made no progress at all. And I certainly don't understand enough about OpenSSL to understand what an X509_NAME is.
I'm compiling a small C file whose function it is to print out an error message if anyone calls one of the 30 or so functions in the file, to indicate that the 30 SSL functions are not supported by the C program. Each function is about 3 lines long (see below). The calling interface is copied from the OpenSSL openssl/X509.h file for win32. (I'm running Windows10 x64, but compiling with VStudio 2017 command line set up for 32bits).
Here is the original interface from the openssl/x509.h include file:
int X509_NAME_get_text_by_NID(X509_NAME *name, int nid, char *buf, int len);
Since the original x509.h include file says inside that "the definition for X509_NAME on Win32 is located in wincrypt.h," I copied the definition for the X509_NAME macro directly into my source file as shown below.
The code for my simple error message function follows. I just copied the interface definition from the openssl/x509.h file and made it into a function:
#define X509_NAME ((LPCSTR) 7) /* copied from wincrypt.h */
int X509_NAME_get_text_by_NID(X509_NAME *name, int nid, char *buf, int len) {
print_error (E_NO_SSL_SUPPORT);
return (-1);
}
When I try to compile the code with the VS 2017 command line compiler for 32bits, I get these error messages. Line 236 contains the troublesome code line int X509_NAME_....
cl /c /Od /nologo /MT /I. "-I..\s" ..\s\stubssl.c
stubssl.c
..\s\stubssl.c(236): error C2143: syntax error: missing ')' before '('
..\s\stubssl.c(236): error C2091: function returns function
..\s\stubssl.c(236): error C2059: syntax error: ')'
..\s\stubssl.c(236): error C2143: syntax error: missing ')' before 'constant'
..\s\stubssl.c(236): error C2143: syntax error: missing '{' before 'constant'
..\s\stubssl.c(236): error C2059: syntax error: 'constant'
..\s\stubssl.c(242): error C2059: syntax error: '<parameter-list>'
c:\stubssl\winxp\make.exe: *** [stubssl.obj] Error 2
I get the same kind of error with another function that is a bit simpler (but that also uses the X509_NAME macro). It starts on line 242 (see the error messages above).
X509_NAME *X509_get_subject_name(X509 *a) {
hio_oerror (E_NO_SSL_SUPPORT);
return (NULL);
}
Does anyone have any idea how I might try to resolve this problem? It seems so simple, yet it has been very elusive for me to solve. I can't imagine how I can be missing ')' before '(' in those lines.
EDIT: My include files in stubssl.c:
#define WIN32_LEAN_AND_MEAN
#include "openssl/ssl.h"
#include "openssl/x509.h"
#include "openssl/bio.h"
#include "openssl/pem.h"
In openSSL, X509_NAME is a type, but <wincrypt.h> defines it as a value (((LPCSTR) 7)). Don't define it yourself, but use the openSSL header, don't include <wincrypt.h> and #define WIN32_LEAN_AND_MEAN to avoid it being included through other windows headers.

enum, unknown type name when typedefd in separate header

I have what I feel is a very basic issue but for some reason I can't seem to resolve it. I am getting the following errors:
drivers/cpufreq/AI_gov.h:37:2: error: unknown type name 'phase_state'
drivers/cpufreq/AI_gov.h:38:2: error: unknown type name 'phase_state'
now in my file AI_gov_phases.h I have the following typdef enum:
typedef enum{
response,
animation,
idle,
load
} phase_state;
now in the file that is throwing the error AI_gov.h I have:
#include "AI_gov_phases.h"
....
struct AI_gov_info{
struct AI_gov_cur_HW* hardware;
struct AI_gov_profile* profile;
phase_state phase;
phase_state prev_phase;
};
typedef enums are definitely one of my weaker areas so any help would be appreciated.

Ruby C extension compile error: expected ‘)’ before ‘event’

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.

Function pointers in C

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);

weird error when passing pthread_t to function

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’).

Resources