user-0 提问: 相同目录下定义在一个头文件的变量可以在另一个头文件直接用吗

回复:
user: user-0
content: 引用 2 楼 max_min_ 的回复:正常情况如果没有包含头文件的话，是应该报错的！  贴代码看看，是不是那里没注意到！  #ifndef X264_SET_H #define X264_SET_H 只有这个

user: user-1
content: 你能确定一定没有引入那个头文件吗？ 可能是引入了其他头文件，其他有文件又引入了那个需要的头文件，你最好找找看，一般是会报错的。

user: user-2
content: 正常情况如果没有包含头文件的话，是应该报错的！  贴代码看看，是不是那里没注意到！

user: user-3
content: 无法理解！  引用 楼主 u010950654 的回复:看到一个几个文件，在一个头文件中定义了一个结构体，在另一个头文件中声明一个函数，参数类型是那个结构体，但是这个头文件没有包含定义结构体的头文件，运行的时候却没有错，请问这个是可以通过编译器设置做到的吗？

user: user-4
content: 肯定是有地方引用了这个头文件的.  你全工程搜索那个头文件的文件名, 应该就能找到.  比如stdafx.h中.

user: user-0
content: x264的09版的   #ifndef X264_SET_H #define X264_SET_H   enum profile_e {     PROFILE_BASELINE = 66,     PROFILE_MAIN     = 77,     PROFILE_EXTENDED = 88,     PROFILE_HIGH    = 100,     PROFILE_HIGH10  = 110,     PROFILE_HIGH422 = 122,     PROFILE_HIGH444 = 144,     PROFILE_HIGH444_PREDICTIVE = 244, };  enum cqm4_e {     CQM_4IY = 0,     CQM_4PY = 1,     CQM_4IC = 2,     CQM_4PC = 3 }; enum cqm8_e {     CQM_8IY = 0,     CQM_8PY = 1 };  typedef struct {     int i_id;      int i_profile_idc;     int i_level_idc;      int b_constraint_set0;     int b_constraint_set1;     int b_constraint_set2;      int i_log2_max_frame_num;      int i_poc_type;     /* poc 0 */     int i_log2_max_poc_lsb;     /* poc 1 */     int b_delta_pic_order_always_zero;     int i_offset_for_non_ref_pic;     int i_offset_for_top_to_bottom_field;     int i_num_ref_frames_in_poc_cycle;     int i_offset_for_ref_frame[256];      int i_num_ref_frames;     int b_gaps_in_frame_num_value_allowed;     int i_mb_width;     int i_mb_height;     int b_frame_mbs_only;     int b_mb_adaptive_frame_field;     int b_direct8x8_inference;      int b_crop;     struct     {         int i_left;         int i_right;         int i_top;         int i_bottom;     } crop;      int b_vui;     struct     {         int b_aspect_ratio_info_present;         int i_sar_width;         int i_sar_height;          int b_overscan_info_present;         int b_overscan_info;          int b_signal_type_present;         int i_vidformat;         int b_fullrange;         int b_color_description_present;         int i_colorprim;         int i_transfer;         int i_colmatrix;          int b_chroma_loc_info_present;         int i_chroma_loc_top;         int i_chroma_loc_bottom;          int b_timing_info_present;         int i_num_units_in_tick;         int i_time_scale;         int b_fixed_frame_rate;          int b_bitstream_restriction;         int b_motion_vectors_over_pic_boundaries;         int i_max_bytes_per_pic_denom;         int i_max_bits_per_mb_denom;         int i_log2_max_mv_length_horizontal;         int i_log2_max_mv_length_vertical;         int i_num_reorder_frames;         int i_max_dec_frame_buffering;          /* FIXME to complete */     } vui;      int b_qpprime_y_zero_transform_bypass;  } x264_sps_t;  typedef struct {     int i_id;     int i_sps_id;      int b_cabac;      int b_pic_order;     int i_num_slice_groups;      int i_num_ref_idx_l0_active;     int i_num_ref_idx_l1_active;      int b_weighted_pred;     int b_weighted_bipred;      int i_pic_init_qp;     int i_pic_init_qs;      int i_chroma_qp_index_offset;      int b_deblocking_filter_control;     int b_constrained_intra_pred;     int b_redundant_pic_cnt;      int b_transform_8x8_mode;      int i_cqm_preset;     const uint8_t *scaling_list[6]; /* could be 8, but we don't allow separate Cb/Cr lists */  } x264_pps_t;  /* default quant matrices */ static const uint8_t x264_cqm_jvt4i[16] = {       6,13,20,28,      13,20,28,32,      20,28,32,37,      28,32,37,42 }; static const uint8_t x264_cqm_jvt4p[16] = {     10,14,20,24,     14,20,24,27,     20,24,27,30,     24,27,30,34 }; static const uint8_t x264_cqm_jvt8i[64] = {      6,10,13,16,18,23,25,27,     10,11,16,18,23,25,27,29,     13,16,18,23,25,27,29,31,     16,18,23,25,27,29,31,33,     18,23,25,27,29,31,33,36,     23,25,27,29,31,33,36,38,     25,27,29,31,33,36,38,40,     27,29,31,33,36,38,40,42 }; static const uint8_t x264_cqm_jvt8p[64] = {      9,13,15,17,19,21,22,24,     13,13,17,19,21,22,24,25,     15,17,19,21,22,24,25,27,     17,19,21,22,24,25,27,28,     19,21,22,24,25,27,28,30,     21,22,24,25,27,28,30,32,     22,24,25,27,28,30,32,33,     24,25,27,28,30,32,33,35 }; static const uint8_t x264_cqm_flat16[64] = {     16,16,16,16,16,16,16,16,     16,16,16,16,16,16,16,16,     16,16,16,16,16,16,16,16,     16,16,16,16,16,16,16,16,     16,16,16,16,16,16,16,16,     16,16,16,16,16,16,16,16,     16,16,16,16,16,16,16,16,     16,16,16,16,16,16,16,16 }; static const uint8_t * const x264_cqm_jvt[6] = {     x264_cqm_jvt4i, x264_cqm_jvt4p,     x264_cqm_jvt4i, x264_cqm_jvt4p,     x264_cqm_jvt8i, x264_cqm_jvt8p };  int  x264_cqm_init( x264_t *h ); void x264_cqm_delete( x264_t *h ); int  x264_cqm_parse_file( x264_t *h, const char *filename );  #endif 我在调用的时候int  x264_cqm_init( x264_t *h );这个是报错的，x264_t未定义，但是原作者的程序却畅通无阻