Page 2 of 2 FirstFirst 12
Results 11 to 13 of 13

Thread: [c] header methodology in C

  1. #11
    Join Date
    Aug 2007
    Beans
    190
    Distro
    Ubuntu

    Re: [c] header methodology in C

    After reading this thread, I have to clarify something and ask a new question. I said in the first post that I included header.c in header.h only because it didn't compile. It was a beginner workaround. Arndt clarified that I should not do that and offered me an alternative solution. I don't include header.c in header.h anymore.

    I have to ask you - which solution is considered best practice? The one offered by Arndt (in which header.h is not included in header.c) or the one in which header.h is included in both header.c and main.c? Sorry for the being insistent but as I said before, the book I am following only hints at this stuff.

  2. #12
    Join Date
    Nov 2005
    Location
    Sendai, Japan
    Beans
    11,296
    Distro
    Kubuntu

    Re: [c] header methodology in C

    It's a good idea to include it in both files, so that the compiler will warn you if protoypes of the function in your header and source files don't match.
    「明後日の夕方には帰ってるからね。」


  3. #13
    Join Date
    May 2006
    Beans
    1,790

    Re: [c] header methodology in C

    Quote Originally Posted by PeterP24 View Post
    After reading this thread, I have to clarify something and ask a new question. I said in the first post that I included header.c in header.h only because it didn't compile. It was a beginner workaround. Arndt clarified that I should not do that and offered me an alternative solution. I don't include header.c in header.h anymore.

    I have to ask you - which solution is considered best practice? The one offered by Arndt (in which header.h is not included in header.c) or the one in which header.h is included in both header.c and main.c? Sorry for the being insistent but as I said before, the book I am following only hints at this stuff.
    In both files, yes. What I meant was that header.c should not be included anywhere.

Page 2 of 2 FirstFirst 12

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •