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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T00:57:06+00:00 2026-06-07T00:57:06+00:00

I am rebuilding an application to comply with MISRA-rules and using QA-C to analyze

  • 0

I am rebuilding an application to comply with MISRA-rules and using QA-C to analyze my code.

One of those annoying rules involve pointers and arrays.
You can’t say:

char foo[10];
char * bar = &(foo[0]);

bar[5] = 'a';

Nor can you then do:

*bar = 'a';
bar++;

My problem involves two functions and a file-scope variable.

Originally this code did the following (bit-pseudocode-like):

static char * bufferPtr;

static void foo_a(char * buffer /* other params */)
{
    bufferPtr = buffer;

    /* some logic goes here */
    switch()
    {
        case 'b':
           foo_b(/* some param */);
}

static void foo_b(/* parameters */)
{
    if (/*something*/)
    {
        /*  some logic */
        foo_c(/* data-param */);
        /* some logic */
    }
    else
    {
        /*  some logic */
        foo_c(/* data-param */);
        /* some logic */
    }
}

static void foo_c(char data)
{
    *buffer++ = data;
}

I’ve tried to rewrite it to the following:

static char (*bufferPtr)[];
static char bufferIndex;

static void foo_a(char buffer[] /* other params */)
{
    bufferPtr = &buffer;
    bufferIndex = 0;

    /* same */
}

static void foo_b(/* parameters */)
{
    /* same */
}

static void foo_c(char data)
{
    (*bufferPtr)[bufferIndex] = data;
    bufferIndex++;
}

But then both misra and my compiler (softune, by Fujitsu) complain.
Compiler says:

assignment incompatible pointer types from CHAR **' toCHAR (*)[]’: operator `=’

Misra says:

[C] Right operand of assignment is not of compatible pointer type.
Address of automatic object exported to a pointer with linkage or wider scope.

However I do need to be able to index an array in the foo_c function. Or are there other ways to and follow misra and make my code work.

If I do the following in the same file:

static CHAR foo[10];
static CHAR (*bar)[];
static void f(void)
{
    bar = &foo;
}

Then nor Misra nor my compiler complain about anything.

  • 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-07T00:57:08+00:00Added an answer on June 7, 2026 at 12:57 am

    I’ve changed the flow of this code to just pass the buffer parameter to each subsequent version.

    It is ugly, but it works and is somewhat safe. ‘according to misra’

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

Sidebar

Related Questions

I am planning to rebuilding the code of one asp.net project to another asp.net
I'm in the process of rebuilding an application (lone developer here) using PHP and
I'm currently rebuilding an existing PHP application using Java. I therefore have an existing
I am rebuilding a web application from an old one with many inconsistencies. I
I'm rebuilding a WPF slide-show application structure that I found in the downloadable code
I am rebuilding indexes using a script which reorganises or rebuilds indexes according to
I'm currently rebuilding an admin application and looking for your recommendations for best-practice! Excuse
I'm rebuilding part of an existing asp application, the new parts are build with
I have an asp.net MVC project hosting a silverlight application. I just started rebuilding
I have a simple application using ADO.NET EntityFramework using a many-to-many relationship between two

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.