CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

V 5.016 Functions may not be nested

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
MeisterOss



Joined: 18 Dec 2013
Posts: 8

View user's profile Send private message

V 5.016 Functions may not be nested
PostPosted: Wed Dec 18, 2013 3:19 am     Reply with quote

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: 19540

View user's profile Send private message

PostPosted: Wed Dec 18, 2013 3:52 am     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Dec 18, 2013 4:16 am     Reply with quote

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: 19540

View user's profile Send private message

PostPosted: Wed Dec 18, 2013 4:33 am     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Dec 18, 2013 4:44 am     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Dec 18, 2013 5:04 am     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Dec 18, 2013 6:48 am     Reply with quote

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: 9243
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Wed Dec 18, 2013 7:21 am     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Dec 18, 2013 7:58 am     Reply with quote

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: 19540

View user's profile Send private message

PostPosted: Wed Dec 18, 2013 8:34 am     Reply with quote

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.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group