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

  • SEARCH
  • Home
  • 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 3271672
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T18:45:03+00:00 2026-05-17T18:45:03+00:00

While debugging some C code with gdb I came across something I’ve not seen

  • 0

While debugging some C code with gdb I came across something I’ve not seen nor heard of before! The compiler (gcc -O0) seems to have created a new type for passing an array of vectors to a function… I think! Have a look at the code and gdb information below:

/* The Vector type - nothing unusual */
typedef struct {
    float x,y,z;
} Vector;

/* The function I was debugging.
 * The second parameter is what seems to have changed */
extern void gui_shader_draw(
    guiShader *shader,
    Vector quad[ 4 ], // << This is the one!
    Vector origin,
    Vector rotation,
    Vector scale,
    bool focus,
    int mode );

I set a breakpoint inside the gui_shader_draw function and this is what I see:

break shader.c:248
Breakpoint 1 at 0x80013ac0: file src/gui/shader.c, line 248.
(gdb) continue
Continuing.
// I have split the next line
Breakpoint 1, gui_shader_draw (
    shader=0x80588ea8,
    quad_t=0x80585fe8, // << What the?
    origin=...,
    rotation=...,
    scale=...,
    focus=false,
    mode=3) at src/gui/shader.c:249

// The values quad_t points to are all good
(gdb) print quad_t[0]
$10 = {x = -320, y = -240, z = 0}
(gdb) print quad_t[1]
$11 = {x = 320, y = -240, z = 0}
(gdb) print quad_t[2]
$12 = {x = 320, y = 240, z = 0}
(gdb) print quad_t[3]
$13 = {x = -320, y = 240, z = 0}

Where did quad_t come from? It’s certainly not a typedef in any of my code. The system header sys/types.h has a quad_t alias (long int) but that doesn’t seem at all related! What’s going on? Have I missed something obvious?

EDIT 1: I must point out that the code compiles and works fine. There are no clashes with some other variable or type called quad_t. I am merely curious about what GCC has done and why.

EDIT 2: As suggested, I had a look over the preprocessor output and indeed all instances of ‘Vector quad[4]’ have been changed to ‘Vector quad_t[4]’, so the name has changed, not the type.

extern void gui_shader_draw(
    guiShader *shader,
    Vector quad_t[ 4 ],
    Vector origin,
    Vector rotation,
    Vector scale,
    _Bool focus,
    int mode
 );

There are no typedefs called ‘quad_t’ in the preprocessor output though. But I did find this in sys/types.h (which I missed before – d’oh!)

/usr/include$ find . | xargs grep -s quad_t
./sys/types.h:typedef    __uint64_t      u_quad_t;
./sys/types.h:typedef    __int64_t       quad_t;
./sys/types.h:typedef    quad_t *        qaddr_t;
./sys/types.h:#  define  quad            quad_t // << There you are!
  • 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-05-17T18:45:04+00:00Added an answer on May 17, 2026 at 6:45 pm

    What happens in your code has absolutely nothing to do with any typedefs, since the change is in no way related to any types at all. What has changes is the name of function parameter not its type, which is immediately obvious from your debugger output.

    Since you see that change in the preprocessor output, the only reasonable explanation is that somewhere in the code there’s a

    #define quad quad_t
    

    So you have to look for #defines for quad, not for quad_t. Needless to say, that #define will not be present in preprocessor output. You have to do a global search in all included (both directly and indirectly) header files.

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

Sidebar

Related Questions

I've found that on some occasions I can edit the source while debugging. Are
pre tags are super-useful for code blocks in HTML and for debugging output while
While debugging through a .NET 3.5 SP1 project which is contacting a local web
Sometimes while debugging, I need to restart a service on a remote machine. Currently,
Is there any way to find all references to an object while debugging?
I would like to see the threads currently active in my application while debugging
Is it possible to iterate collection and list only filtered object information while debugging
Every once in a while, typically when I stop debugging in our UI assembly,
While going through university and from following the development of SO, I've heard a
While the C# spec does include a pre-processor and basic directives (#define, #if, etc),

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.