View previous topic :: View next topic |
Author |
Message |
MeisterOss
Joined: 18 Dec 2013 Posts: 8
|
V 5.016 Functions may not be nested |
Posted: Wed Dec 18, 2013 3:19 am |
|
|
Hi everybody,
I have some problems with my code and I don't understand it. I'm using CCS V5.016.
main C-File
Code: |
include "24EP512GU810.h"
#include "sample_def.h"
#define _SAMPLE_APPLICATION_
#include "sampleappl.h"
#undef _SAMPLE_APPLICATION_
#include "File1.c"
#include "File2.c"
#include "File3.c"
void APPL1(UINT16 Var)
{
}
UINT16 APPL2(void)
{
return STATUSCODE_NOERROR;
}
UINT16 APPL3 (void)
{
return STATUSCODE_NOERROR;
}
.
.
.
int main(void)
{
HW_Init();
MainInit();
bRunApplication = TRUE;
do
{
MainLoop();
} while (bRunApplication == TRUE);
HW_Release();
return 0;
}
|
sampleappl.h
Code: |
#ifndef _SAMPLE_APPL_H_
#define _SAMPLE_APPL_H_
#include "sample_def.h"
#define SAMPLE_INPUT_SIZE 4
#define SAMPLE_OUTPUT_SIZE 4
#endif
#ifdef _SAMPLE_APPLICATION_
#define PROTO
#else
#define PROTO extern
#endif
PROTO void APPL1(UINT16 VAR);
PROTO UINT16 APPL2(void);
PROTO UINT16 APPL3(void);
#undef PROTO
|
And the Error Code is:
Quote: |
rror 173 "sampleappl.c" Line 89(6,22): Functions may not be nested
*** Error 173 "sampleappl.c" Line 108(8,32): Functions may not be nested
*** Error 127 "sampleappl.c" Line 110(5,11): Return value not allowed in void function
*** Error 173 "sampleappl.c" Line 124(8,31): Functions may not be nested
*** Error 127 "sampleappl.c" Line 126(5,11): Return value not allowed in void function
*** Error 173 "sampleappl.c" Line 145(8,30): Functions may not be nested
*** Error 127 "sampleappl.c" Line 147(5,11): Return value not allowed in void function
.
.
.
|
Has anybody an idea what kind of problem this is?
Why the compiler doesn`t recognize the prototypes in sampleappl.h ?
Thank you |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19541
|
|
Posted: Wed Dec 18, 2013 3:52 am |
|
|
Look again at your code. You are including the same files multiple times. When this is done, you have to ensure the files 'test' if they are already loaded, and don't redefine/reload the same things multiple times. However you are not posting the files that are complaining (.c, not .h), but the basic problem will be the same. |
|
|
MeisterOss
Joined: 18 Dec 2013 Posts: 8
|
|
Posted: Wed Dec 18, 2013 4:16 am |
|
|
Hi Ttelmah
Thanks for your reply.
I don't include the h-file several times, I include it only in the main-File (sampleappl.c) . That's the reason why I'm so confused. Even when I set the endif in the h-file at the end, the error occurs. So I think this can't be the error. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19541
|
|
Posted: Wed Dec 18, 2013 4:33 am |
|
|
Well, I can see sample_def.h being included twice in what you post, let alone in the other stuff.... |
|
|
MeisterOss
Joined: 18 Dec 2013 Posts: 8
|
|
Posted: Wed Dec 18, 2013 4:44 am |
|
|
I defined in the sample_def.h
Code: |
#ifndef _SAMPLE_DEF_H_
#define _SAMPLE_DEF_H_
.
.
.
.
#end_if
|
I did this in every h-File I included. Normally this prevent the problem of including h-files several times. |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Wed Dec 18, 2013 5:04 am |
|
|
MeisterOss wrote: | I did this in every h-File I included. Normally this prevent the problem of including h-files several times. | Yes, that is the normal way to do it. In the sampleappl.h you originally posted the #define - endif combination was only in the first 10 lines of the file instead from first to last line.
In your main.c you had: Code: | #define _SAMPLE_APPLICATION_
#include "sampleappl.h"
#undef _SAMPLE_APPLICATION_
| Another recipe for disaster. The first define causes the header file not to run the code that it is supposed to, and then you #undef the define again???
You say you fixed these problems, we cannot check because you didn't post new code.
You are make somewhere a silly mistake because you overlook a detail. It is like you saying you don't include the same header file twice where we can see in the small code parts you posted that you do.
Another important thing is that the error message suggests you are including the same .C-file multiple times. Where you are only talking about checking the .H-files. Check your code for this, or perhaps add the same #ifdef trick to your C-files as well.
We don't see your code, only what you post here. The easiest and quickest thing for you to do is to make the code smaller. Remove large parts until you have something that does compile again. The last part you removed and that made it compile again is where your problem is.
This is a very important bug hunting technique. A bit like binary search.
You can also do it the other way around. Start with something that works and then add more modules until it fails, the last added part will contain the error.
For us to help you further you will have to post a small but complete program anyway, so why not use this as a bug hunting technique to find the problem yourself? |
|
|
MeisterOss
Joined: 18 Dec 2013 Posts: 8
|
|
Posted: Wed Dec 18, 2013 6:48 am |
|
|
Hi ckielstra
The code works as long as I don`t include any other c-File . The included c-File doesn`t even include any other file.
I removed all the #defines and #undefs to make it`s more simple but the error still occures
Thanks for you advices |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9244 Location: Greensville,Ontario
|
|
Posted: Wed Dec 18, 2013 7:21 am |
|
|
good news is you're getting close to the problem !!
now, what is the error message you're getting ? |
|
|
MeisterOss
Joined: 18 Dec 2013 Posts: 8
|
|
Posted: Wed Dec 18, 2013 7:58 am |
|
|
temtronic wrote: | good news is you're getting close to the problem !!
now, what is the error message you're getting ? |
The error message is still the same than in post one |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19541
|
|
Posted: Wed Dec 18, 2013 8:34 am |
|
|
Now, the post just made probably illustrates exactly the sort of problem.....
You omitted the closing bracket on the opening 'quote', so the quote designation didn't work. One tiny error ruins the post.
I'd guess something like a missing bracket inside the first C file you include. Try using the 'match brace' operation (assuming you have the IDE), on the very first bracket, and the very last bracket in the file. |
|
|
|