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

The Archive Base Latest Questions

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

Attempting to compile the following code under Qt SDK 4.7.4 for Desktop – MinGW

  • 0

Attempting to compile the following code under Qt SDK 4.7.4 for Desktop – MinGW 4.4 results in the compiler error below:

#include <QtCore/QCoreApplication>
#include <QMap>
struct Buffer
{
   char data[4];
};
// A Bucket needs to reserve 16 chars worth of Buffers
typedef Buffer Bucket[(16 * (sizeof (char))) / (sizeof (Buffer))];
typedef QMap<QString, Bucket *> BucketMap;
int main(int argc, char *argv[])
{
   BucketMap bucket;
   bucket.insert(QString("foo"), new Bucket()); //compile error
   return 0;
}
../test/main.cpp: In function 'int main(int, char**)':
../test/main.cpp:13: error: no matching function for call to 'QMap<QString, Buffer (*)[4]>::insert(QString, Buffer*)'
../../../QtSDK/Desktop/Qt/4.7.4/mingw/include/QtCore/qmap.h:556: note: candidates are: QMap<Key, T>::iterator QMap<Key, T>::insert(const Key&, const T&) [with Key = QString, T = Buffer (*)[4]]
mingw32-make.exe[1]: *** [debug/main.o] Error 1
mingw32-make.exe: *** [debug] Error 2

I have tried converting this to an quivalent example using std::string and std::map to the same effect. I have presented the Qt version because it is more compact and ultimately the form that my project requires.
I’m guessing that I am simply missing something about how the typedef is ultimately interpreted. Why is the second argument to insert apparently a Buffer * (not Buffer(*)[4]), and how can I fix it?

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

    Simple answer: The types don’t match.

    What you actually need to know: You cannot invoke a new expression for an array type. Therefore, the following two are not equivalent (and the first isn’t legal):

    typedef T TArr[4]; TArr * p = new TArr;  // #1
    
    T * q = new T[4];                        // #2
    

    The language just doesn’t work that way. The second version creates a dynamic array, while the first version would like to create a single dynamic object of type “array of 4 T”, which is not possible. Instead, new TArr is actually the same as new T[4], and so the result is a dynamic array of four Ts.*

    You should basically just change your map’s value type to either Buffer * or std::array<Buffer, 4> * or std::unique_ptr<Buffer[]> or std::unique_ptr<std::array<Buffer, 4>>, whichever you prefer.

    *) This is exactly the reason why the following code is very problematic: template <T> void foo() { T * p = new T; delete p; } Imagine you say foo<int[4]>();…

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

Sidebar

Related Questions

I am attempting to compile the following template based code in VC++ 2005. #include
When attempting to compile my C# project, I get the following error: 'C:\Documents and
While attempting to cross-compile ICU using android-ndk-r7 in Linux, the following error occurs after
When attempting to compile I am getting the following errors Error(16,8): PLS-00103: Encountered the
I am receiving the following compile time error when attempting to extend the SimpleButton
I am attempting to compile C code that utilizes the following within GNU readline.
I'm attempting to get the following code from nmdepend to compile const std::string Bfd::packageName(const
I am getting the following error message when compiling or attempting to run my
I am attempting to call a C++ API from python. Following is the code
I'm attempting to following the tutorials found here: http://www.ifadey.com/2010/06/crud-using-jquery-and-codeigniter/ My code is updated to

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.