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

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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:30:07+00:00 2026-05-27T06:30:07+00:00

The following code compiles fine on majority of compilers (include Microsoft Visual Studio’s –

  • 0

The following code compiles fine on majority of compilers (include Microsoft Visual Studio’s – cl, Minimalist GNU for Windows – MinGW) but fails on Digital Mars Compiler – dmc with the error: Error: type qualifiers and static can only appear in outermost array of function parameter

const int MAXLENGTH32 = 32;
typedef char String32[MAXLENGTH32];

void f1(const String32 tokens[]) {

}

int main() {

    return 0;
}

I would like to state the following:

  1. The first reason I am posting this is to get expert opinion on why the code fails on a popular compiler (Bjarne Stroustrup himself recommends it http://www2.research.att.com/~bs/compilers.html). The main problem seems to be the use of const with the parameter. If you remove const, the code compiles fine on the DMC compiler.

  2. The second important reason is that in my investigation on the possible explanation for compilation failure, I did not come across any conclusive explanation. Worse, I came across the suggestion: “C++ programmers to just avoid using const”. The poster went on to say that its rather difficult to figure out just what the specifications says about the usage of const in a scenario like above and that these kinds of things are why const, as a type modifier, is not in D (- to paraphrase sort of).

  3. The last personal reason for this post is that most exceptional things I have learnt about C++ language have been borne out of not taking a stance like it-compiles-on-all-the-rest-so-damn-it-and-move-on. Yes. Am eager to hear expert opinion on what could make what would seem like normal code fail on DMC compiler just like that. Thanks.

  • 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-27T06:30:08+00:00Added an answer on May 27, 2026 at 6:30 am

    The obvious explination is that there is a bug in dmc. The error
    message is excedingly confusing: for starters, static cannot appear
    anywhere in a function parameter, outermost or otherwise. As for type
    qualifiers, the standard is clear that type qualifiers on an array apply
    to the individual elements of the array (and that this applies
    recursively). Written canonically, your function declaration would be:

    void f1(String32 const* tokens)
    

    , which, after application of the typedef, becomes:

    void f1( char const (*tokens)[MAXLLENGTH32] );
    

    Which is perfectly legal.

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

Sidebar

Related Questions

I came across the following code that compiles fine (using Visual Studio 2005): SomeObject
I have the following code which compiles and runs fine under Visual Studio 2008
In Microsoft Oslo SDK CTP 2008 (using Intellipad) the following code compiles fine: module
Visual Studio 2008 I am using the following source code that compiles ok using
I am unclear about the following. First, this code compiles fine: #include <vector> typedef
I had the following code line which compiles just fine under g++ and Visual
The following code compiles in Visual C++ and gcc, but fails with Code Warrior
the following code compiles fine under gcc: class vec3 { private: float data[3]; public:
The following code compiles fine, but does not allow the user to choose whether
This question is related to this question. The following code compiles fine VC9 compiler

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.