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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T08:17:23+00:00 2026-05-28T08:17:23+00:00

I am trying to build the M-SIM architecture simulator, but when I run the

  • 0

I am trying to build the M-SIM architecture simulator, but when I run the make utility, gcc reports this error (it is not even a warning)

note: expected ‘char *’ but argument is of type ‘const char *’

Since when this is considered an error. Is there any flags that can bypass this check?

  • 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-28T08:17:24+00:00Added an answer on May 28, 2026 at 8:17 am

    This is an error because passing a const char* argument to a function that takes a char* parameter violates const-correctness; it would allow you to modify a const object, which would defeat the whole purpose of const.

    For example, this C program:

    #include <stdio.h>
    
    void func(char *s) {
        puts(s);
        s[0] = 'J';
    }
    
    int main(void) {
        const char message[] = "Hello";
        func(message);
        puts(message);
        return 0;
    }
    

    produces the following compile-time diagnostics from gcc:

    c.c: In function ‘main’:
    c.c:10:5: warning: passing argument 1 of ‘func’ discards qualifiers from pointer target type
    c.c:3:6: note: expected ‘char *’ but argument is of type ‘const char *’
    

    The final message is marked as a “note” because it refers to the (perfectly legal) declaration of func(), explaining that that’s the parameter declaration to which the warning refers.

    As far as the C standard is concerned, this is a constraint violation, which means that a compiler could treat it as a fatal error. gcc, by default, just warns about it and does an implicit conversion from const char* to char*.

    When I run the program, the output is:

    Hello
    Jello
    

    which shows that, even though I declared message as const, the function was able to modify it.

    Since gcc didn’t treat this as a fatal error, there’s no need to suppress either of the diagnostic messages. It’s entirely possible that the code will work anyway (say, if the function doesn’t happen to modify anything). But warnings exist for a reason, and you or the maintainers of the M-SIM architecture simulator should probably take a look at this.

    (Passing a string literal to func() wouldn’t trigger these diagnostics, since C doesn’t treat string literals as const. (It does make the behavior of attempting to modify a string literal undefined.) This is for historical reasons. gcc does have an option, -Wwrite-strings, that causes it to treat string literals as const; this actually violates the C standard, but it can be a useful check.)

    As I mentioned in a comment, it would be helpful if you’d show us the code that triggers the diagnostics.

    I even downloaded and built the M-SIM architecture simulator myself, but I didn’t see that particular message.

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

Sidebar

Related Questions

When trying to build I get this error: $ make CC=i686-w64-mingw32-gcc CC aes.c i686-w64-mingw32-gcc:
I'm trying build a MVC framework, but I'm confused about manage themes. Well... I
I'm trying build a regex that will replace any characters not of the format:
Trying to build a plugin effect that will some what look better than this
Trying to build my android project with Buildr (Apache), but can't find any info
I trying to build an application that is using the torrent technology to make
Trying to build a linq query based on parameters a user selects (reporting) but
I'm brand new to this and I'm trying build a simple layout of divs.
Upon trying to build even the simplest Metro application in Visual Studio, I get
I am trying build an AST for the below grammer using ANTLR condition_in :

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.