Confusing Multiple Folder and files in Studio

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

In Atmel Studio 7.0, will you put your project files format similar to atmel start where you will have

 

folder such as 

include > to have all .h files here

src > to have multiple splitted .c file here

util > to have some application .c here

 

I find this way is more difficult to focus and debug as variable is spreaded in multiple files and need to know where to put extern.   

 

But this seem to be easier to copy for future project and ease portability. Any advice and tips what shall be the better way.  

  

 

 

 

 

 

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

This really has nothing to do with Atmel Studio - whether you choose to organise/segregate your files into folders or not really doesn't depend on what IDE you use.

 

hamisu wrote:
I find this way is more difficult to focus and debug as variable is spreaded in multiple files

The alternative is to just have one huge file - which can then become unwieldy.

 

If the project is well-structured, with good modularity, there should not be a great deal of referencing variables across files ...

 

You're looking to maximise Cohesion, and minimise Coupling:

 

 

Note that this is general Computer Science / Software Engineering stuff - not specific to C

 

Maybe take a look at this Tutorial: https://www.avrfreaks.net/forum/tut-modularizing-c-code-managing-large-projects

 

and need to know where to put extern.   

that's a fairly basic C programming thing: http://c-faq.com/decl/decldef.html

 

 

seem to be easier to copy for future project and ease portability

And for maintainability.

 

EDIT: It also makes it easier in large project with multiple people all working on the code

 

Yes, these are the key advantages.

 

With a decent modern IDE, you should have code browsing facilities so that you can easily find the definitions & uses of variables & functions across multiples files.

 Atmel  Microchip Studio certainly has this.

 

 

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...
Last Edited: Wed. Jan 12, 2022 - 09:32 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1


The fact that you are using a powerful IDE like Studio 7 surely means it does not really matter how the text is split as the file browser ("VassistX" in tha case of Studio 7) will find symbols wherever you happen to put them.

 

Having said that it is very common practice to split projects into a tree such as:

 

 

That's simply so that if you are browsing around a repository (quite possibly in a system like github) things are neatly divided so if you want to know what the interface to module2 is you look in the solution/project/module2/include directory for the exported header files it provides.

 

As for knowing where to put "extern" you put it in a .h file when a variable is being made publicly accessible to some other client of that module.