Whatever struct my_error_mgr
is, the compiler can't find its declaration as a type. You need to include the header that has that declaration.
Variable has incomplete type 'struct my_error_mgr'
-
20-09-2022 - |
Question
When I try to build this code, the line struct my_error_mgr jerr;
gives the error "Variable has incomplete type 'struct my_error_mgr'
#import "Engine.h"
#include "jpeglib.h"
@implementation Engine
+(void)test{
struct jpeg_decompress_struct cinfo;
struct my_error_mgr jerr;
FILE * infile;
if ((infile = fopen(filename, "rb")) == NULL) {
fprintf(stderr, "can't open %s\n", filename);
return 0;
}
cinfo.err = jpeg_std_error(&jerr.pub);
jerr.pub.error_exit = my_error_exit;
if (setjmp(jerr.setjmp_buffer)) {
jpeg_destroy_decompress(&cinfo);
fclose(infile);
return 0;
}
jpeg_create_decompress(&cinfo);
jpeg_stdio_src(&cinfo, infile);
(void) jpeg_read_header(&cinfo, TRUE);
jvirt_barray_ptr* coeffs_array;
coeffs_array = jpeg_read_coefficients(&cinfo);
BOOL done = FALSE;
for (int ci = 0; ci < 3; ci++)
{
JBLOCKARRAY buffer_one;
JCOEFPTR blockptr_one;
jpeg_component_info* compptr_one;
compptr_one = cinfo.comp_info + ci;
for (int by = 0; by < compptr_one->height_in_blocks; by++)
{
buffer_one = (cinfo.mem->access_virt_barray)((j_common_ptr)&cinfo, coeffs_array[ci], by, (JDIMENSION)1, FALSE);
for (int bx = 0; bx < compptr_one->width_in_blocks; bx++)
{
blockptr_one = buffer_one[0][bx];
for (int bi = 0; bi < 64; bi++)
{
blockptr_one[bi]++;
}
}
}
}
write_jpeg(output, &cinfo, coeffs_array); // saving modified JPEG to the output file
jpeg_destroy_decompress(&cinfo);
fclose(infile);
}
@end
When I try to comment out all lines related to this error, I then get a EXC_BAD_ACCESS
runtime error on the line
(void) jpeg_read_header(&cinfo, infile);
I'm trying to modify the DCT coefficients of a saved JPEG image in iOS with the eventual goal of creating a JPEG steganography app. I have the following code attempting to add one to each DCT coefficient. I'm using the libjpeg library. The code is a combination of Objective-C and C.
A quick note, the variable filename is equal to "/Users/ScottBouloutian/Library/Application Support/iPhone Simulator/7.0.3/Applications/27A0450E-4685-4C3E-AAC8-A0CC6C85359E/Crypsis.app/screen.jpg", which is the path to the JPEG image I am trying to modify.
What is wrong with the code I have? Is it something dumb like a missing include or something wrong with my file path?
Solution
OTHER TIPS
I was getting the following error in my code:
Variable has incomplete type 'RCTLayoutMetrics' (aka 'struct CG_BOXABLE')
I upgraded to Xcode Version 9.2 (9C40b) and it fixed the issue.