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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T15:40:06+00:00 2026-06-02T15:40:06+00:00

I am reading code to define the interrupt vector for an STM32 here .

  • 0

I am reading code to define the interrupt vector for an STM32 here. For some reason, both __attribute__((weak)) and #pragma weak are used:

void __attribute__((weak)) NMI_Handler(void); /* NMI Handler */ // [line 12]
#pragma weak NMI_Handler = Default_Handler    /* NMI handler */ // [line 48]

Somehow it feels that using both __attribute__((weak)) and #pragma weak is redundant.

Can we do without one of them? Is this style standard?

  • 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-02T15:40:07+00:00Added an answer on June 2, 2026 at 3:40 pm

    You are right but…

    #pragma weak NMI_Handler = Default_Handler 
    

    alone can accomplish what is intended. But it would be good to add __attribute__((weak)) to the function prototypes for the following reason –

    Assume that the file is a huge one with definitions and prototypes spilled all over the file. Now you use an IDE/Editor to jump to the prototype of NMI_Handler and when you arrive there and don’t see __attribute__((weak)) attached to NMI_Handler you might as well assume that NMI_Handler is defined somewhere else and go on a goose hunt and end up nowhere! Now, as they’ve explicitly added __attribute__((weak)), you get an idea that this function’s definition might not be there and you can now search for any pragma aliasing instead of trying to find the actual definition of the function which doesn’t/may not exist!

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

Sidebar

Related Questions

I found this while reading some source code. #define MACRO(x) if((void) 0, (x)); else
I`m reading the code of some open source project. I see that in one
When I reading the code of CodeIgniter,I found some functions written as follows: function
I am reading a code where it is supposed to implement a bit vector
I have some code reading a text file and scanning for words between brackets:
#undef GOOGLE_DISALLOW_EVIL_CONSTRUCTORS #define GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(TypeName) \ TypeName(const TypeName&); \ void operator=(const TypeName&) I'm, reading open
I was reading some code from the Doom 3 SDK ( in a VS
Reading some source code, I have found next traits definition: namespace dds { template
I have been reading through several websites and even used NVIDA's code as a
I'm reading external C code, and I found the following line of code: #define

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.