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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T09:29:20+00:00 2026-05-29T09:29:20+00:00

How can I work around the Visual Studio Visual C #C2148 error? Here is

  • 0

How can I work around the Visual Studio Visual C #C2148 error? Here is the code that produces the error:

#define ACOUNT 2000
#define BCOUNT 9000
#define CCOUNT 195

struct s_ptx {

      int pvCount[ACOUNT][BCOUNT][CCOUNT];
} ;

This produces a VStudio 2010 Visual C (compiling under 64bit) error #C2148:
error C2148: total size of array must not exceed 0x7fffffff bytes

I know I could dynamically allocate the pvCount 3d array, but then I’d have to do a zillion alloc’s and free’s. I have 192 gig of memory, so I’m trying to find a compiler switch or option that allows something of this size.

Edit: The complicating issue I left out trying to simplify things is that ptx is a pointer that at runtime is used as an array of structs:

ptx *Ptx        =  (ptx *)   calloc(10,  sizeof(ptx));
for (int i = 0; i < 10; ++i)
    {
     Ptx->pv = (int (*)[BCOUNT][CCOUNT] )  malloc( (unsigned long) ACOUNT * BCOUNT *CCOUNT * sizeof(int));

}


 for (int jav = 0; jav < 10; ++jav)
        for (int j = 0; j < ACOUNT; ++j)
            for (int k = 0; k < BCOUNT; ++k)
                for (int m = 0; m < CCOUNT; ++m)
                    Ptx[jav].pv[j][k][m] = j + k + m;

So when I run the code I get an access violation error, presumably because by doing the dynamic allocation I am no longer able to use: Ptx[jav].pv[j][k][m]

  • 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-29T09:29:21+00:00Added an answer on May 29, 2026 at 9:29 am

    You don’t need zillion mallocs. just:

    int (*arr)[BCOUNT][CCOUNT]=malloc((size_t)ACOUNT*BCOUNT*CCOUNT*sizeof int);
    

    Edit: the cast to size_t is necessary, to not overflow the int.

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

Sidebar

Related Questions

I have some experience in ASP.Net and can work my way around it without
Why can't you do this and is there are work around? You get this
Does anyone have an example of script that can work reliably well across IE/Firefox
I need some help modifying the Webform Module so that it can work for
Its a well known fact that a static method can work only on static
(Using Visual Studio 2008, and Silverlight 3) -I've really looked around for this one,
I have a Visual Studio 2010 solution that contains C# (managed), C++/CLI (unmanaged) and
I tried compile apache 2.2, my Visual Studio 2008 returned error on RC. After
Whenever I type out tags that don't require an end tag, Visual Studio adds
Our developers frequently work in large Visual Studio projects and we often run command-line

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.