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 7926485
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T18:47:25+00:00 2026-06-03T18:47:25+00:00

When compiling C source code with either gcc or Clang, I always use the

  • 0

When compiling C source code with either gcc or Clang, I always use the -g flag to generate debugging information for gdb.

gcc -g -o helloworld helloworld.c

I noticed that some people recommend -g3 instead. What is the difference between the -g and -g3 flags? Also is there a difference between -g and -ggdb?

  • 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-03T18:47:36+00:00Added an answer on June 3, 2026 at 6:47 pm

    From the docs:

    -g

    Produce debugging information in the operating system’s native format (stabs, COFF, XCOFF, or DWARF 2). GDB can work with this
    debugging information. On most systems that use stabs format, -g
    enables use of extra debugging information that only GDB can use; this
    extra information makes debugging work better in GDB but probably
    makes other debuggers crash or refuse to read the program. If you want
    to control for certain whether to generate the extra information, use
    -gstabs+, -gstabs, -gxcoff+, -gxcoff, or -gvms (see below).

    …


    -ggdb

    Produce debugging information for use by GDB. This means to use the most expressive format available (DWARF 2, stabs, or the native
    format if neither of those are supported), including GDB extensions if
    at all possible.


    -gvmslevel

    Request debugging information and also use level to specify how much information. The default level is 2. Level 0 produces no
    debug information at all. Thus, -g0 negates -g.

    ….

    Level 3 includes extra information, such as all the macro definitions
    present in the program. Some debuggers support macro expansion when
    you use -g3.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using gcc -MM to generate prerequisites of dependencies rules for compiling source
When compiling shared libraries in gcc the -fPIC option compiles the code as position
I had to modify some open source code to use in a C project.
I'm compiling ADW source code. ( https://github.com/AnderWeb/android_packages_apps_Launcher/archives/b28e9e417c81857cfd2e0265c3c6d409d6c8d0f1 ) I wanna add widget more quickly,
I have a Makefile.am for compiling Ocaml source code with ocamlbuild . However, even
I am compiling linux source code for android emulator. When i execute make command(for
Possible Duplicate: Compiling C code for .NET I have a bunch of C source
I try to use JavaCompiler to compile source code. class A{int i;}; class B
Currently attempting to debug with KDbg / gdb the source code for Towers of
After compiling PHP from source are the devel libraries still needed? For example, 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.