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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T02:31:06+00:00 2026-06-16T02:31:06+00:00

I am getting this error Use of undeclared identifier ‘new’ on this line of

  • 0

I am getting this error

Use of undeclared identifier ‘new’

on this line of code

Byte* decompressedBytes = new Byte[COMPRESSION_BLOCK];

This is my method that this line of code appears in.

//  Returns the decompressed version if the zlib compressed input data or nil if there was an error
+ (NSData*) dataByDecompressingData:(NSData*)data{
    Byte* bytes = (Byte*)[data bytes];
    NSInteger len = [data length];
    NSMutableData *decompressedData = [[NSMutableData alloc] initWithCapacity:COMPRESSION_BLOCK];
    Byte* decompressedBytes = new Byte[COMPRESSION_BLOCK];

    z_stream stream;
    int err;
    stream.zalloc = (alloc_func)0;
    stream.zfree = (free_func)0;
    stream.opaque = (voidpf)0;

    stream.next_in = bytes;
    err = inflateInit(&stream);
    CHECK_ERR(err, @"inflateInit");

    while (true) {
        stream.avail_in = len - stream.total_in;
        stream.next_out = decompressedBytes;
        stream.avail_out = COMPRESSION_BLOCK;
        err = inflate(&stream, Z_NO_FLUSH);
        [decompressedData appendBytes:decompressedBytes length:(stream.total_out-[decompressedData length])];
        if(err == Z_STREAM_END)
            break;
        CHECK_ERR(err, @"inflate");
    }

    err = inflateEnd(&stream);
    CHECK_ERR(err, @"inflateEnd");

    delete[] decompressedBytes;
    return decompressedData;
}

I am not sure why this is appearing like this. This code is from ObjectiveZlib and have read through it several times and am not trying to use it in my own code to decompress a zlib NSData object but am having this stopping me from progressing.

any help would be greatly appreciated.

  • 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-06-16T02:31:09+00:00Added an answer on June 16, 2026 at 2:31 am

    This code is Objective-C++. You’re trying to compile it as Objective-C. Rename the file to end in .mm instead of .m and it should work.

    Specifically, the new and delete operators are C++ operators. They don’t exist in C. Objective-C is a superset of C, and Objective-C++ is a superset of C++. However since those appear to be the only C++-isms in this code, if you’d rather stick with Objective-C, you can fix it by replacing two lines:

    1. Replace new Byte[COMPRESSION_BLOCK] with (Byte*)malloc(sizeof(Byte) * COMPRESSION_BLOCK)
    2. Replace delete[] decompressedBytes with free(decompressedBytes)
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i try to use TBXML and getting this error TBXML class method +tbXMLWithURL not
I'm getting this fatal error message: Fatal error: Can't use method return value in
I can't seem to get round this error; use of undeclared identifier 'ageBy'. I
I am getting this error in a PHP class... Fatal error: Can't use method
I am getting a use of undeclared identifier error in my json but I
I am getting 'SBJSON' undeclared (first use in this function) error when i try
I am getting this error when I use this code sub search { my
I have below code. I am getting error as 'list' undeclared (first use in
I am getting this error when I use the Linq expression of var emp
I'm getting this error when I use MarshallingView to marshal my list (java.util.List) of

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.