Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8820925
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T05:43:41+00:00 2026-06-14T05:43:41+00:00

I’ve tried to get my makefile to compile a file that requires -std=c99 to

  • 0

I’ve tried to get my makefile to compile a file that requires -std=c99 to run. In this case, its to get a “for-loop” through.

This is my code, (its been used “tab” before “$(CC)” ):

CC = gcc
CFLAGS = -c -std=c99

...

Download.o : Download.c
    $(CC) $(CFLAGS) Download.c

Download.c contains methods used to download elements from the web

Error message

$ make
gcc -c -std=c99 Download.c
gcc Download.c -o Program
Download.c: In function ‘downloadImageparts’:
Download.c:11:2: error: ‘for’ loop initial declarations are only allowed in C99 mode
Download.c:11:2: note: use option -std=c99 or -std=gnu99 to compile your code
Download.c:13:3: error: ‘for’ loop initial declarations are only allowed in C99 mode
make: *** [comp] Error 1

Attemt to debug

If I run gcc -c -std=c99 Download.c in terminal it works fine.

This problems appears when run in Linux.

SOLVED:

I created a dummy project to show my lecturer, in an attempt to solve my problem. In the dummy project all works fine with the code described. For some reason my code works on place but not in the other. If someone reading this having the same problem as me and would like to see an example project. let me know and I’ll write the code here. Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T05:43:42+00:00Added an answer on June 14, 2026 at 5:43 am

    You’re looking at the wrong rule. Download.c is actually compiling fine, but the linking stage is wrong.

    $ make
    gcc -c -std=c99 Download.c  # Compile
    gcc Download.c -o Program   # Link
    

    Fix the make rule that links the program. It should probably look something like this:

    Program: a.o b.o c.o
        $(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
    

    While you’re at it, I suggest a more complete Makefile will look something like this:

    all: Program
    clean:
        rm -f Program *.o
    .PHONY: all clean
    
    # -c is implicit, you don't need it (it *shouldn't* be there)
    # CC is also implicit, you don't need it
    CFLAGS := -std=c99 -g -Wall -Wextra
    
    Program: a.o b.o c.o
        $(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
    
    # Make will automatically generate the necessary commands
    # You just need to name which headers each file depends on
    # (You can make the dependencies automatic but this is simpler)
    a.o: a.c header.h
    b.o: b.c header.h header2.h
    c.o: c.c header.h
    

    Examples of how to do it wrong

    Linker flags are actually fairly touchy! Be sure to type in the line above exactly as I have written it, and don’t assume that what you’ve written is equivalent. Here are some examples of slightly different commands that are wrong and should not be used:

    # WRONG: program must depend on *.o files, NOT *.c files
    Program: a.c b.c c.c
        $(CC) ...
    
    # WRONG: -c should not be in CFLAGS
    CFLAGS := -c -std=c99
    
    Program: a.o b.o c.o
        # WRONG: $(CFLAGS) should not be here
        # you are NOT compiling, so they do not belong here
        $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)
    
        # WRONG: $(LIBS) MUST come at the end
        # otherwise linker may fail to find symbols
        $(CC) $(LDFLAGS) -o $@ $(LIBS) $^
    
        # WRONG: do not list *.o files, use $^ instead
        # otherwise it is easy to get typos here
        $(CC) $(LDFLAGS) -o $@ a.o b.o c.o $(LIBS)
    
        # WRONG: $(LDFLAGS) must be at the beginning
        # it only applies to what comes after, so you
        # MUST put it at the beginning
        $(CC) -o $@ $(LDFLAGS) $^ $(LIBS)
    
        # WRONG: -c flag disables linking
        # but we are trying to link!
        $(CC) $(LDFLAGS) -c -o $@ $^ $(LIBS)
    
        # WRONG: use $(CC), not gcc
        # Don't sabotage your ability to "make CC=clang" or "make CC=gcc-4.7"
        gcc $(LDFLAGS) -o $@ $^ $(LIBS)
    
        # WRONG: ld does not include libc by default!
        ld $(LDFLAGS) -o $@ $^ $(LIBS)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have just tried to save a simple *.rtf file with some websites and
I know there's a lot of other questions out there that deal with this
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a small JavaScript validation script that validates inputs based on Regex. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.