"Declaration Not allowed here" and "Constant Expression" Error in C

user2828488

I used Microsoft Visual Studio to write a C code in C++ project and It's working fine there when I convert the file extension from my.cpp to my.c and tried to run in via TurboC++ 3.0 then it gives me number of errors like "Constant Expression Required" and "Declaration is not allowed here". I tried to run my code online compiler but its not giving me these error there.

Can anyone help me with this ?

I hope it's due to C99 mode but not confirmed. TurboC++ 3.0 Supports C99 or not ?

Note: I can't share my code directly here due to project research work , If anyone want to have a look at my code I can send you via private message , Sorty for that

haccks

The error: Declaration Not allowed here is due to the mixed type declaration of variables and the error: Constant Expression required is because of the variable length arrays.
Mixed type variables and variable length arrays are are allowed in C99 and latter. Neither MSVC nor Turbo C++ supports C99.

I tried to run my code online compiler but its not giving me these error there.

This is because almost all new (and online) C compilers support C99.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

variable declaration not allowed here

From Dev

variable declaration not allowed here

From Dev

static assert c++ - constant expression error

From Dev

Why is variable declaration not allowed here?

From Dev

understand a constant expression error

From Dev

"expected constant expression" Error

From Dev

C struct object Stack - function call is not allowed in constant expression (error)

From Dev

C++ Error: 'x' is not a constant expression, how to fix?

From Dev

'this' cannot be used in a constant expression error (C++) with this-> pointer variable

From Dev

Compile error: Constant expression required

From Dev

Compile error: Constant expression required

From Dev

c++: "expected constant expression"

From Dev

Creating a constant Expression in C#

From Dev

java.util.Scanner Object Declaration not Allowed Here

From Dev

fatal error C1017: invalid integer constant expression when using "#if (false)"

From Dev

Constant expression required error in switch statement with strings

From Dev

Maven android plugin error "constant expression required"

From Dev

constant expression required error when run this program

From Dev

MS Visual Studio Error: Expected Constant Expression

From Dev

std::addressof as a constant expression in C++17

From Dev

About cast in integer constant expression (in standard C)

From Dev

How to define a constant by expression in C++?

From Dev

C2057: expected constant expression

From Dev

Constant expression required error setting optional parameter in function

From Dev

Is this error message correct: non-type template argument is not a constant expression

From Dev

`static constexpr` function called in a constant expression is...an error?

From Dev

PHP 7, Fatal error: Constant expression contains invalid operations

From Dev

'Constant Expression Required' Error while keeping formal argument as a constant

From Dev

Getting error: "variable cannot appear in a constant-expression"

Related Related

  1. 1

    variable declaration not allowed here

  2. 2

    variable declaration not allowed here

  3. 3

    static assert c++ - constant expression error

  4. 4

    Why is variable declaration not allowed here?

  5. 5

    understand a constant expression error

  6. 6

    "expected constant expression" Error

  7. 7

    C struct object Stack - function call is not allowed in constant expression (error)

  8. 8

    C++ Error: 'x' is not a constant expression, how to fix?

  9. 9

    'this' cannot be used in a constant expression error (C++) with this-> pointer variable

  10. 10

    Compile error: Constant expression required

  11. 11

    Compile error: Constant expression required

  12. 12

    c++: "expected constant expression"

  13. 13

    Creating a constant Expression in C#

  14. 14

    java.util.Scanner Object Declaration not Allowed Here

  15. 15

    fatal error C1017: invalid integer constant expression when using "#if (false)"

  16. 16

    Constant expression required error in switch statement with strings

  17. 17

    Maven android plugin error "constant expression required"

  18. 18

    constant expression required error when run this program

  19. 19

    MS Visual Studio Error: Expected Constant Expression

  20. 20

    std::addressof as a constant expression in C++17

  21. 21

    About cast in integer constant expression (in standard C)

  22. 22

    How to define a constant by expression in C++?

  23. 23

    C2057: expected constant expression

  24. 24

    Constant expression required error setting optional parameter in function

  25. 25

    Is this error message correct: non-type template argument is not a constant expression

  26. 26

    `static constexpr` function called in a constant expression is...an error?

  27. 27

    PHP 7, Fatal error: Constant expression contains invalid operations

  28. 28

    'Constant Expression Required' Error while keeping formal argument as a constant

  29. 29

    Getting error: "variable cannot appear in a constant-expression"

HotTag

Archive