Best practices for including header and source files

Sysprogs forums Forums VisualGDB Best practices for including header and source files

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #27895
    GeneM
    Participant

    I’m still very new to C/C++ and VisualGDB so a lot of my programs are based on examples from the STM32 examples, the VisualGDB examples and a variety of other sources.  These examples typically include .h and .c files from folders buried in various folders scattered all over the place.  When I build a new project that combines parts from multiple examples, I spend a lot of time hunting down all the .h and .c files I need.

    I’ve just starting building 2 generic folders, one called STMHeaders and one called STMSource where I’ve been putting every .h and every .c file I need for any project using ST Micro controllers.  Then I can add these 2 paths to the project Property Pages->C/C++->General->Additional Include Directories option for every VisualGDB project using a STM processor and I should be good.

    2 questions:

    1. Does this seem like a reasonable approach and if not is there a Best Practice for this?
    2. When I add a file to either of those folders, an open VisualGDB project won’t automatically detect the new file when I build andI get an undefined reference error or file not found error.  How do I make VisualGDB look for new files in my 2 folders every time I build?

    Thanks – Gene

    #27898
    support
    Keymaster

    Hi,

    This is really a generic C++ question and not something specific to VisualGDB, so the amount of help we can provide here is very limited. If you are new to C/C++, we would advise looking up and following a few beginner’s tutorials that explain source and header files. It could save you immense time compared to trying to guess the correct configuration.

    You can also find a few best practice articles published by Microsoft by searching for “Visual Studio add cpp file”. As VisualGDB embedded projects inherit the Visual Studio’s project system, everything described in those articles will apply to VisualGDB projects as well.

    Regarding your second question, neither Visual Studio nor VisualGDB would automatically build all files from a specific folder, as it could normally cause confusion. Explicitly adding the source files to Solution Explorer (and using virtual folders to organize them) is the way to go for C/C++ projects.

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.