Unknown Type Name for Struct

Go To Last Post
4 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi All,

 

I am getting the following error:

Error unknown type name 'UARTData' SyringeTesting \SyringeTesting\main.c 63

 

I have two different structs that I have created shown here:

typedef struct {

     char address[4];           //Name of syringes, i.e. "X91"

     uint32_t location;         //Current location of syringe in steps, 0 is home

     char status;                 //current status, i.e. 'b' for busy

     size_t size;                  //size of syringe

     uint8_t power;            //Syringe power setting

     char* stepMode;         //stepping mode

     uint16_t speed;          //speed in steps/second of syringe

     char dir;                    //direction which the syringe is moving 'd'ispense or 'f'ill

} Syringe;



typedef struct {

      uint8_t rxFlag;

      char messageTerminator;

      char* buffer;

      uint32_t buffLoc;

} UARTData;

 

They are defined in SyringeLibrary.h and UARTLibrary.h, respectively. Both files are linked to my solution by choosing "Add Existing Item", selecting the .h and associated .c files, and choosing "Add as Link" in Atmel Studio 7.

 

This is the relevant chunk of my main():

main(){

     Syringe s1;

     Syringe s2;

     Syringe s3;

     UARTData u0; 

}

 

When the UARDData declaration is in, i get an error. But if i take it out it works fine, the Syringe declarations have no issues. 

 

I have tried not using a typedef and instead declaring u0 as: 

 

struct UARTData u0;  

 

but then the compiler says the storage size of u0 is unknown.

 

I would greatly appreciate any suggestions!

This topic has a solution.

-Josh

Last Edited: Fri. Apr 20, 2018 - 04:24 PM
This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Linking them to the project is pointless. It is ONLY #include that matters. Where those types are used, above the point of use there MUST be a #include so that the compiler will have seen the declaration before the point of use.
.
BTW you haven't come from Arduino have you? To supposedly make things simple they scan for any .h that are needed and make hidden #include's which trains programmers in completely the wrong way to think #include is optional.
.
PS forgot to say that if you #include and it reports not found because the headers are some distance from the project you will need one or more -I which you setup in Studio under "Directories"

Last Edited: Fri. Apr 20, 2018 - 02:11 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

That fixed it, thank you for the quick response!

 

I have used Arduino in the past, that might have mixed me up.

 

I thought I had tried to use an #include but I may be mistaken. At any rate it is working now, thanks!

-Josh

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

jwaltgrant wrote:
That fixed it

So please mark the solution - see Tip #5

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...