header-files

Why could a header file be including itself?

╄→гoц情女王★ 提交于 2019-12-03 16:18:35
Can anyone think of any scenario in which a header file includes itself? I saw it in one of the program and this inclusion is under conditional compilation block for which at least i could not find any true condition.But, I was thinking could there be any technical requirement for such scenario? Yes, if you are trying to win the International Obfuscated C Code Contest . Here's a nice example (the source file is called isaak.c ): main(){} #define P define #P U ifdef #P main Si #U y #undef y #include "isaak.c" Pb #else char*K="4499999;8 9+jW*':'TZhD m:*h.4-j'9(z7Q>r*:G#FS]mATIdMZY^HaKFZZ\ JyJw

Why is const unnecessary in function declarations in header files for parameters passed by value?

五迷三道 提交于 2019-12-03 15:47:13
I was recently reading about the usage of const keyword as function arguments in C and the way to use that has been mentioned in When and for what purposes should the const keyword be used in C for variables and been accepted as correct answer. In this post, one point mentions that Never use const in a function prototype for a parameter passed by value. It has no meaning and is hence just 'noise'. I used this way and it works for me but I am not sure why that is a noise for parameters passed by value and yet not a noise for the parameters passed by reference (more aptly the pointer values in C

Header dependency in automake

回眸只為那壹抹淺笑 提交于 2019-12-03 13:38:53
问题 I'd like to create a Makefile.am file which generates one header file mentioned in a xxx.c file. Let's say that xxx.c contains: #include <version.h> ... and that I have a rule to create it at the end of Makefile.am : version.h: echo '#define VERSION "'`hg id`'"' > version.h.tmp cmp version.h.tmp version.h || mv version.h.tmp version.h What do I have to change to make the xxx.c compilation depend on version.h ? I tried nodist_progname_SOURCES=version.h , but that doesn't seem to do it. 回答1:

How to define an array of strings of characters in header file?

China☆狼群 提交于 2019-12-03 13:19:23
问题 I have many different 3 axis sensors I am writing test code for. In the C files for each of them, I have the same char string defined: char axis[3][8] = {"X", "Y", "Z"} which I use when I "for" loop results to print the axis that is failing like this: DEVICETEST_LOG("%s Failed %s axis for Min range\n",device_name[DUT], axis[i]); I was thinking to save some space I could define a character string array in a header file to use all over the place. I have tried a number of things, but I can't

How to include header files in Visual Studio 2008?

怎甘沉沦 提交于 2019-12-03 13:10:47
I am currently trying to compile a simple program that includes two header files. I see them in the Solution Explorer, where I included them through "include existing files". However, when I run my program it get the following error. fatal error C1083: Cannot open include file: 'FileWrite.h': No such file or directory. THe problem is that I see the file included in the Header's folder and in the code I have written: #include "FileWrite.h" and then the rest of the program code. Is there something else needed to do so that the compiler can see the header file and link it to the .cpp file I'm

Using a struct in a header file “unknown type” error

試著忘記壹切 提交于 2019-12-03 12:27:59
问题 I am using Kdevelop in Kubuntu. I have declared a structure in my datasetup.h file: #ifndef A_H #define A_H struct georeg_val { int p; double h; double hfov; double vfov; }; #endif Now when I use it in my main.c file int main() { georeg_val gval; read_data(gval); //this is in a .cpp file } I get the following error: georeg_chain.c:7:3: error: unknown type name 'georeg_val' (This is in the georeg_val gval; line) I would appreciate if anyone could help me resolve this error. 回答1: In C one has

putting function definitions in header files

流过昼夜 提交于 2019-12-03 11:40:52
问题 If you want to put function definitions in header files, it appears there are three different solutions: mark the function as inline mark the function as static put the function in an anonymous namespace (Until recently, I wasn't even aware of #1.) So what are the differences to these solutions, and when I should I prefer which? I'm in header-only world, so I really need the definitions in the header files. 回答1: The static and unnamed namespace versions end up being the same: each Translation

JDK 1.8 on Linux missing JNI include file

↘锁芯ラ 提交于 2019-12-03 11:03:17
I am trying to compile the following project: https://github.com/entropia/libsocket-can-java I always get this error message? Does anyone know how to fix it, is it possibly a bug in JDK 1.8.0.11 on Linux (x64 Debian Wheezy)? In file included from jni/de_entropia_can_CanSocket.h:2:0, from jni/cansocket.cpp:23: /opt/jdk1.8.0_11/include/jni.h:45:20: fatal error: jni_md.h: No such file or directory #include "jni_md.h" ^ It seems so. #include "jni_md.h" would include the file in the same directory as jni.h , but it is placed in linux folder. In previous JDK versions it seems that file and another

Where does Ruby's have_header method look for header files?

安稳与你 提交于 2019-12-03 08:23:26
On a CentOS 5.7 box, I'm having trouble installing the newest version of the mysql2 gem; it's not finding errmsg.h: /usr/bin/ruby extconf.rb checking for rb_thread_blocking_region()... yes checking for rb_wait_for_single_fd()... no checking for mysql_query() in -lmysqlclient... yes checking for mysql.h... no checking for mysql/mysql.h... yes checking for errmsg.h... no ----- errmsg.h is missing. please check your installation of mysql and try again. ----- *** extconf.rb failed *** The mysql header files exist at /usr/include/mysql. An older version of the gem exists on the server, so it must

C header issue: #include and “undefined reference”

孤人 提交于 2019-12-03 07:42:22
问题 Alright, I've been trying to work with this for the longest time, and I simply can't seem to get it to work right. I have three files, main.c , hello_world.c , and hello_world.h . For whatever reason they don't seem to compile nicely, and I really just can't figure out why... Here are my source files. First hello_world.c: #include <stdio.h> #include "hello_world.h" int hello_world(void) { printf("Hello, Stack Overflow!\n"); return 0; } Then hello_world.h, simple: int hello_world(void); And