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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T19:45:59+00:00 2026-06-11T19:45:59+00:00

I got a code from an old project implementing AES on 802.15.4 It defines

  • 0

I got a code from an old project implementing AES on 802.15.4
It defines the the default key like this:

static uint8_t default_key_source[8] = {0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};

and afterwards define a table which uses this in the following manner:

uint8_t mac_key_table[34] =
{
    // KeyIdLookupList[1].LookupData : macDefaultKeySource || g_Sec_KeyIndex_1
    default_key_source[0], // LookupData[0]
    default_key_source[1], // LookupData[1]
    default_key_source[2], // LookupData[2]
    default_key_source[3], // LookupData[3]
    default_key_source[4], // LookupData[4]
    default_key_source[5], // LookupData[5]
    default_key_source[6], // LookupData[6]
...
}

I get “expression must have a constant value” error on compilation. which is strange because it used to compile on different compiler (don’t know exactly which, but I’m using IAR embedded workbench for ARM)

I tried adding const before the static declaration of the default_key_source. but it didn’t help, I get that the compiler can’t initialize a structure with variables, however these variables are constants, so what’s the problem here ?

  • 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-11T19:46:01+00:00Added an answer on June 11, 2026 at 7:46 pm

    An easy way to deal with such a situation in C is to use a macro, to be sure that you’d have to define the constants only in one place:

    #define DEFAULT_KEY_SOURCE 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
    
    // if you really need that variable
    static default_key_source[8] = { DEFAULT_KEY_SOURCE };
    
    uint8_t mac_key_table[34] =
    {
      DEFAULT_KEY_SOURCE,
      ...
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I got this code from our frontend guy for headings: <h2 class=headline><span>Foobar</span></h2> The span
I got this code from the wordpress <head profile=http://gmpg.org/xfn/11> What does this means? what
I got this code from someone, it's almost perfect to create a dynamic breadcrumb,
I got this code from someone and it works very well, I just want
i got a jquery code from this link (end of page): How to scroll
I've got an android project that I started from an old standard Java project,
I got below code from http://msdn.microsoft.com/en-us/library/dd584174(office.11).aspx for adding custom property in webpart tool pane.
I got following code from net and it looks everything is proper but i'm
first post here, and probably an easy one. I've got the code from Processing's
I got some sample code from the net here: http://www.javadb.com/sending-a-post-request-with-parameters-from-a-java-class That works fine. It

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.