Expected expression before = token, warum!?
-
Hallo Leute
Der Compiler gibt mir die im Threadtitel genannte Fehlermeldung aus, ich verstehe beim besten Willen nicht warum.
Hier die organisation meines Programmes:
1 main file
1 header file "my_audiolib" mit dazugehörigem c file mit den implementationenIm Header file habe ich ein Struct WAVETABLE deklariert, und in der Main funktion rufe ich eine funktion auf, welche ein solches WAVETABLE dynamisch generieren soll:
Header: "my_audiolib.h"
#ifndef MY_AUDIOLIB_H #define MY_AUDIOLIB_H struct WAVETABLE { int size; double content[1]; }; typedef struct WAVETABLE WAVETABLE; WAVETABLE* create_wave(int size); #endif // MY_AUDIOLIB_H
"my_audiolib.c"
#include <stdio.h> #include <conio.h> #include <stdlib.h> #include <math.h> #include "my_audiolib.h" WAVETABLE* create_wave(int size) { WAVETABLE* wave = malloc(sizeof(WAVETABLE)+(size-1)*sizeof(double)); if(wave == NULL) { printf("failed to allocate memory for table\n"); exit(1); } wave->size = size; //fill_table(wave, size); return wave; }
main.c
#include <stdio.h> #include <conio.h> #include <stdlib.h> #include <math.h> #include "my_audiolib.h" #define fs = 48000; #define table_size = 4096; int main(int argc, char *argv[]) { WAVETABLE* wave = create_wave(table_size); return 0; }
Ich sehe einfach nicht wo das Problem liegt, wäre super, wenn mir jemand da kurz weiterhelfen könnte.
-
Schau dir nochmal an, wie #define funktioniert. Und gewöhn dir an, die Stelle, an der der Fehler gemeldet wird, mitzunennen.
-
Ok, danke dir, das wars.