我對C++非常陌生,我試圖盡力從一開始就擁有一個好的項目結構。 我現在用的是C庫libjpeg
,幷包括在我的.cpp
與使用在標題中找不到C++ extern
extern "C" {
#include <jpeglib.h>
}
它工作得很好,直到我刪除它放在一個頭文件,它現在給了我以下錯誤:
inc/jpeg_utils.h: 6: inc/jpeg_utils.h: extern: not found
inc/jpeg_utils.h: 8: inc/jpeg_utils.h: Syntax error: "}" unexpected
我的頭jpeg_utils.h
:
#ifndef JPEG_UTILS_INCLUDE
#define JPEG_UTILS_INCLUDE
#include <stdio.h>
extern "C" {
#include <jpeglib.h>
}
int read_jpeg_file(char *filename, int decompression);
void write_jpeg_file(char *filename, unsigned char *image_buffer, int image_width, int image_height, int quality);
#endif
而且在頂部:
#include "../inc/jpeg_utils.h"
我誤解了標題的使用嗎?
是否將標題重命名爲jpeg_utils.hpp會改變什麼? – Jovasa
@Jovasa爲什麼要改變文件的名稱,有什麼區別? –
不幸的不是。 – SarahHime