Как в Keil создавать многофайловый проект?
Добавлено: Пт дек 12, 2025 19:48:56
Вроде по коду я ошибок не вижу, но тем не менее пишет что есть ошибки.
Добавлено after 10 minutes 7 seconds:
\\\\ main.c
#include "main.h"
int main(void){
INIT();
while(1);
return 0;
}
\\\ main.h
#ifndef MAIN_H
#define MAIN_H
#include <stdint.h>
#include "FM33A0XXEV.h"
#include "init.h"
#endif
\\\init.c
#include "init.h"
#include <stdint.h>
#pragma GCC diagnostic ignored "-Wgnu-binary-literal"
void INIT(void){
rcc();
}
void rcc(void){
CMU->RCHFCR |= (0b0001U << 1);
}
\\\init.h
#ifndef MAIN_H
#define MAIN_H
#include "main.h"
void INIT(void);
void rcc(void);
#endif
\\\ Ошибка
Build started: Project: test
*** Using Compiler 'V6.19', folder: 'C:\Programs\keil\ARM\ARMCLANG\Bin'
Build target 'Target 1'
init.c(12): error: use of undeclared identifier 'CMU'
CMU->RCHFCR |= (0b0001U << 1);
^
1 error generated.
compiling init.c...
main.c(4): error: call to undeclared function 'INIT'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
INIT();
^
1 error generated.
compiling main.c...
compiling system_FM33A0XXEV.c...
".\test.axf" - 2 Error(s), 0 Warning(s).
Target not created.
Build Time Elapsed: 00:00:01
Добавлено after 10 minutes 7 seconds:
\\\\ main.c
#include "main.h"
int main(void){
INIT();
while(1);
return 0;
}
\\\ main.h
#ifndef MAIN_H
#define MAIN_H
#include <stdint.h>
#include "FM33A0XXEV.h"
#include "init.h"
#endif
\\\init.c
#include "init.h"
#include <stdint.h>
#pragma GCC diagnostic ignored "-Wgnu-binary-literal"
void INIT(void){
rcc();
}
void rcc(void){
CMU->RCHFCR |= (0b0001U << 1);
}
\\\init.h
#ifndef MAIN_H
#define MAIN_H
#include "main.h"
void INIT(void);
void rcc(void);
#endif
\\\ Ошибка
Build started: Project: test
*** Using Compiler 'V6.19', folder: 'C:\Programs\keil\ARM\ARMCLANG\Bin'
Build target 'Target 1'
init.c(12): error: use of undeclared identifier 'CMU'
CMU->RCHFCR |= (0b0001U << 1);
^
1 error generated.
compiling init.c...
main.c(4): error: call to undeclared function 'INIT'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
INIT();
^
1 error generated.
compiling main.c...
compiling system_FM33A0XXEV.c...
".\test.axf" - 2 Error(s), 0 Warning(s).
Target not created.
Build Time Elapsed: 00:00:01