Thread: Preventing Creation Of Precompiled Header Files

  1. #1
    Registered User
    Join Date
    May 2016
    Posts
    104

    Preventing Creation Of Precompiled Header Files

    The school bot that grades projects at my school has a file size limit of around 1M. My current project is well below that mark, however, for some reason during compilation a precompiled header file, .pch, is created for each of my headers; around 700KB each one. This makes my project too big for the bot to handle.

    After searching online, I see that pchs in gcc, are only created after specifying the -x flag, which I'm not using. The macs at my school use Clang, not gcc, but I believe they behave similarly in this respect. So I am at a loss here. How can I prevent these files .pch from being created in the first place?

    Thank you guys.

  2. #2
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    Do you submit only headers and C source files?

    If yes, verify you are not submitting an header with the filename used by the build system to create Precompiled Header (PCH).

    If no, then read up on what type of project files you are submitting about what controls PCH creation.

    Tim S.
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

  3. #3
    Registered User
    Join Date
    May 2016
    Posts
    104
    Yes, I only submit headers and source files, plus my Makefile. It is possible that I inadvertently used an "illegal" name, I will investigate. For now, I got around the issue by placing a line with find, xargs and rm in the make all recipe to get rid of the .pch files right after compilation.

    Thanks.

  4. #4
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    If you want to share your Makefile and we can see if there's anything interesting there. The only thing I saw in a bit of websearching is that clang might be tempted to make a pch file if you specify the header in the compile line (instead of just using #include instead), so perhaps that has happened somehow.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Precompiled header question
    By donglee in forum C++ Programming
    Replies: 13
    Last Post: 01-22-2009, 01:23 AM
  2. precompiled header file
    By George2 in forum C++ Programming
    Replies: 20
    Last Post: 04-07-2008, 08:14 AM
  3. precompiled header compiled as C++ when I want C
    By ulillillia in forum Windows Programming
    Replies: 1
    Last Post: 12-17-2006, 06:58 AM
  4. precompiled header
    By l2u in forum Windows Programming
    Replies: 2
    Last Post: 11-26-2006, 08:22 PM
  5. Can't open precompiled header
    By minesweeper in forum C++ Programming
    Replies: 2
    Last Post: 12-08-2002, 06:28 PM

Tags for this Thread