"daven" <dave@dave.com> wrote in message news:i94c0p$v3u$1@news.eternal-september.org...> On 13/10/2010 13:52, Meindert Sprang wrote: > > "daven"<dave@dave.com> wrote in message > > news:i948q7$9jb$1@news.eternal-september.org... > >> > >> You can't put functions in header files, they go in .c files. So put > >> the above in a .c file and then in a header file put: > > > > Of course you can! Whether it is good practise is a differentmatter....> > > > Meindert > > > > > Well yes you can but if you then include that header file in more than > one .c file things are still not going to work.It will if you use the fairly standard #infdef <filename>_H #define <filename>_H <... code goes here ..> #endif" trick. Which you have to use anyway for "normal" header files too... Meindert
interrupts with FX2
Started by ●October 12, 2010
Reply by ●October 14, 20102010-10-14
Reply by ●October 14, 20102010-10-14
On 14/10/2010 08:39, Meindert Sprang wrote:> "daven"<dave@dave.com> wrote in message > news:i94c0p$v3u$1@news.eternal-september.org... >> On 13/10/2010 13:52, Meindert Sprang wrote: >>> "daven"<dave@dave.com> wrote in message >>> news:i948q7$9jb$1@news.eternal-september.org... >>>> >>>> You can't put functions in header files, they go in .c files. So put >>>> the above in a .c file and then in a header file put: >>> >>> Of course you can! Whether it is good practise is a different > matter.... >>> >>> Meindert >>> >>> >> Well yes you can but if you then include that header file in more than >> one .c file things are still not going to work. > > It will if you use the fairly standard > > #infdef<filename>_H > #define<filename>_H > <... code goes here ..> > #endif" > > trick. > Which you have to use anyway for "normal" header files too... > > Meindert > >I'm not sure that it will, doesn't that work only per .c file? This is useful when a .c file includes a header file that then inludes another header file which is already included in the original .c file. If the header file is included in different .c files then it will be compiled for each .c file. That is any previously defined symbols are cleared at the end of compilation of each .c file.
Reply by ●October 14, 20102010-10-14
"daven" <dave@dave.com> wrote in message news:i96d97$1f3$1@news.eternal-september.org...> On 14/10/2010 08:39, Meindert Sprang wrote: > > It will if you use the fairly standard > > > > #infdef<filename>_H > > #define<filename>_H > > <... code goes here ..> > > #endif" > > > > trick. > > Which you have to use anyway for "normal" header files too... > > > > Meindert > > > > > I'm not sure that it will, doesn't that work only per .c file? This is > useful when a .c file includes a header file that then inludes another > header file which is already included in the original .c file.Darn, you're right. That is exactly what bit me when I was handed a project which contained exactly one C file and 50 H files containing code and declarations.... (stupid CCS compiler....). Meindert