Thread: Help with a Makefile (IDEs are 4 teh newbz)

  1. #1
    Registered User MutantJohn's Avatar
    Join Date
    Feb 2013
    Posts
    2,665

    Help with a Makefile (IDEs are 4 teh newbz)

    Yeah, yeah, yeah, IDEs are good for complex and long code.

    But here's a Makefile I have which I modified from a C-syntax Makefile so I have no idea if it's good practice.

    Basically, the compiler no longer complains about unused or unitialized values and I want it to because I'm bad a programming like that.

    Code:
    MKFILE    = Makefile
    
    
    GCC       = g++ -g -O3 -W -Wall -Wextra -lpthread
    
    
    CSOURCE   = main.cpp
    CHEADER   = structures.h
    OBJECTS   = ${CSOURCE:.cpp=.o}
    EXECBIN   = regulus
    
    
    all : ${EXECBIN}
    
    
    ${EXECBIN} : ${OBJECTS}
    	${GCC} -o $@ ${OBJECTS} -lm
    
    
     
    %.o : %.c
    
    
    	${GCC} -c $<
    
    
    
    
    clean :
    	- rm ${OBJECTS} ${EXECBIN}
    
    
    
    
    again :
    	${MAKE} clean all

  2. #2
    Registered User
    Join Date
    May 2010
    Posts
    4,632
    You may want to add a few more warning options.

    Jim

  3. #3
    Registered User MutantJohn's Avatar
    Join Date
    Feb 2013
    Posts
    2,665
    Lol thank you for the link.

    And also, I should've changed line 21 to "%.o : %.cpp" lol :P

  4. #4
    Internet Superhero
    Join Date
    Sep 2006
    Location
    Denmark
    Posts
    964
    Specifically, i would add -ansi and -pedantic. They make the compiler warn you about using GCC specific extensions, which might mean the code won't work with another compiler.

    Unless ofcourse you're purposefully using GCC extensions.
    How I need a drink, alcoholic in nature, after the heavy lectures involving quantum mechanics.

  5. #5
    Registered User
    Join Date
    Apr 2013
    Posts
    1,658
    Wouldn't you need to include a dependency that shows main.o is dependent on main.cpp and structures.h?

  6. #6
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,666
    > Basically, the compiler no longer complains about unused or unitialized values and I want it to because I'm bad a programming like that.
    If you're bad at programming, how much worse are you at debugging?

    Because being silent about potential errors doesn't mean they suddenly vanish.

    If you're bad at programming, you should be looking to get maximum help from your tools at every step of the way, and that means turning the warning level up to the max.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C/C++ IDEs
    By valthyx in forum C++ Programming
    Replies: 6
    Last Post: 08-02-2011, 01:02 PM
  2. IDEs: I want non uniform fonts!
    By Mario F. in forum General Discussions
    Replies: 33
    Last Post: 12-16-2009, 11:44 PM
  3. IDEs and editors of different kind
    By Kempelen in forum C Programming
    Replies: 3
    Last Post: 09-29-2008, 05:11 PM
  4. IDEs and Resource Editors
    By wierdbeard65 in forum Windows Programming
    Replies: 14
    Last Post: 06-07-2007, 11:27 AM
  5. Two IDEs on same comp?
    By Confederate in forum C++ Programming
    Replies: 3
    Last Post: 05-04-2006, 08:18 PM