cancel
Showing results for 
Search instead for 
Did you mean: 

PSoC Creator & Designer Software

New Contributor II

Dear all,

   

I have received the job to organize and clean a project. The project has a main.c file, in which, you can  find several #includes and also functions definitions. There are also several header files. Among these header files, there is one called all.h in which you can find not only function protoypes, but also function definition and many defines.

   

I would like to leave the main.c file only with the function itself without any function definition. Also do the same with the all.h file.

   

I have started by estracting a very simple function from the main.c file in a file called oximetro.c. Also I have created a oximetro.h file with the variables and functions prototype used in oximetro.c. I have include in main.c the oximetro.h. After a couple of days trying different things I always get the error above (in the subject of this message).

   

Has anyone the idea of the origin of the problem? Any literature to read about includes, defines...etc in C programming? I attach the whole project bundle (almost 5M)  if someone want to have a look.

   

I have to say I have not many experience in C programming.

   

Thanks in advance.

   

Joaquin.

0 Likes
Reply
11 Replies
Esteemed Contributor II

You probably have created an #include loop. so that one file #includes another which in turn #includes the first again.

   

A .h-file usually starts with

   

#ifndef UniqueName

   

#define UniqueName

   

// Here the declarations go...

   

#endif

   

For "UniqueName" best will be to use the filename (without ".h"), you may append a "_h" to it to be sure the name is unique troughout your project.

   

This pattern will prevent every .h-file from beeing expanded more than once, so that no symbol gets declared doubly and there can be no #include-loop. The c-sources within all.c are imho displaced and I would suggest to extract them and create an .c and h. pair for them.

   

 

   

Hope that helps

   

Bob

0 Likes
Reply
Honored Contributor II

The exit code 1 just indicates that an error happened during compile. The real error message is somewhere in the gcc output. And its that one that gives you a hint about the actual problem. (And its the one that you should ask about)

0 Likes
Reply
Esteemed Contributor II

@hli

   

That is the usual way, but in this case it was the only one errormessage that was provided. Since the compilation took abnormally long I assume an infinitive source-loop.

   

 

   

Bob

0 Likes
Reply
New Contributor II

Hi all:

   

Thank you for yur answers.

   

I have followed your recomendations. I added to each .h-file a:

   

*****************************************

   

#ifndef UniqueName_h

   

#define UniqueName_h

   

....

   

#endif

   

*****************************************

   

Beside, I have split in two files (all.h and all.c) the original all.h file which was containing c-sources. However I still have the same problem, the same error. I attach a new bundle of the project, in case someone wants to have a look. Could you check I I have done what you proposed?

   

Any other idea?

   

Thanks in advance,

   

Joaquin.

0 Likes
Reply
Esteemed Contributor II

Last error is a linker error (LD) which you all can see when you open the "Output" tab. Some symbols are not defined becaouse you commented them, others are doubly defined and you'll have to seek for them.

   

 

   

Bob

0 Likes
Reply
New Contributor II

Dear all,

   

Still working in this issue and almost desperate. I have problems with "struct redefinition" and conflit "type". I have tryied almost everything, reading tutorials and examples,  but, It is clear, that there are something that I dont understand. Could some have a look to the attached bundled project and tell me how could I solve only one of the problem that appears? I think, solving one will solve all.

   

Thanks in advance,

   

Joaquín.

0 Likes
Reply
Esteemed Contributor

You have multiple defs of structures, for example mens_lcd defined in AF_textos.h and

   

AF_textos_def.h

   

 

   

You have errors in size of struc initialization, for example

   

 

   

        } lcd_Textos[ 78 ] = {                 //I had to count to get the 78 parameter. You had 3 as parameter

   

 

   

Regards, Dana.
 

0 Likes
Reply
Esteemed Contributor II

I would suggest you to

   

1st open all your self written files .h and .c

   

2nd Search for your doubly defined names using "all open files" listed in the error-messages and comment one of the declarations

   

In the file device.h is written in the first lines

   

/*******************************************************************************
* This file is automatically generated by PSoC Creator
* and should not be edited by hand.
*
 

   

I would suggest you to move your own definitions out of here and put them into another appropiate place.

   

 

   

I cannot find the declaration for "Enviar_Byte_UART_PRN()".

   

 

   

In a couple of your texts you are using non-ascii characters which are flagged as illegal.

   

 

   

Bob

0 Likes
Reply
New Contributor II

Dear All,

   

Finally I got solve all the problems.

   

Last problems I had were in relation with "struct" initialization. For example, the followinfg struct that was working in the project I was given to correct and clean, was defined in a "file.h" as following:

   

struct mens_prn_chip{
         char cab_serv_chip[38];       
        } prn_Chip[1] = {
            {"  DATE   TEMPS   Kg   cm  Max Min RC "} };

   

Then I create two files:

   

* file.h

   

struct mens_prn_chip{
         char cab_serv_chip[38];       
        } prn_Chip[1];

   

* and file.c with the following:

   

struct mens_prn_chip prn_Chip[1] = {
            {"  DATE   TEMPS   Kg   cm  Max Min"} };

   

Just in case someone can help. The confusion came because the first original struct was working in the original project I was given to work on.

   

Anyway thank you for your support.

   

Joaquin.

0 Likes
Reply
Esteemed Contributor II

You are always welcome!

   

 

   

Bob

0 Likes
Reply
Esteemed Contributor

You are always welcome!

   

 

   

Dana.

0 Likes
Reply