header-files

Is it bad practice to use a C header instead of its C++ equivalent in C++ (e.g. stdio.h instead of cstdio)?

青春壹個敷衍的年華 提交于 2019-12-01 09:29:53
It seems that a lot of people include example.h instead of cexample in their C++ code. I know that everything in the C++ versions is declared in namespace std, but I'm not aware of any other differences. So why do people use the C headers, and is it okay to do so? The difference between the two is that the C headers that C++ imported (by prefixing with c and removing the .h suffix) are in namespace std . This so any call or use of a standard facility is prefixed with std:: , for uniformity. It's The Standard Way Of Doing Things(tm) . Unless of course you already have a bunch of C code in which

How to add Objective-C Bridging Header entry?

限于喜欢 提交于 2019-12-01 09:16:50
I have a Swift project and have add a cocoapod, which is written in Objective-C. It has header and implementation files. From what I understand, to use/import these files into my Swift files, I need to add a bridging file. I found this site describing how to do this manually, since the Objective-C files are already part of my project (from the cocoapod). http://www.learnswiftonline.com/getting-started/adding-swift-bridging-header/ 1.) Navigate to your project build settings and find the “Swift Compiler – Code Generation” section. You may find it faster to type in “Swift Compiler” into the

How to add Objective-C Bridging Header entry?

隐身守侯 提交于 2019-12-01 06:30:52
问题 I have a Swift project and have add a cocoapod, which is written in Objective-C. It has header and implementation files. From what I understand, to use/import these files into my Swift files, I need to add a bridging file. I found this site describing how to do this manually, since the Objective-C files are already part of my project (from the cocoapod). http://www.learnswiftonline.com/getting-started/adding-swift-bridging-header/ 1.) Navigate to your project build settings and find the

FLTK in MSVC needs x11 headers?

♀尐吖头ヾ 提交于 2019-12-01 05:58:34
I'm trying to learn how to use FLTK right now (In MSVC 2008). I got all the the libraries compiled correctly, but when I tried to run this program: #include "FL/Fl.H" #include "FL/Fl_Window.H" #include "FL/Fl_Box.H" int main(int argc, char *argv[]) { Fl_Window *window = new Fl_Window(340, 180); Fl_Box *box = new Fl_Box(20, 40, 300, 100, "Hello, World!"); box->box(FL_UP_BOX); box->labelfont(FL_BOLD + FL_ITALIC); box->labelsize(36); box->labeltype(FL_SHADOW_LABEL); window->end(); window->show(); return Fl::run(); } I got this error 1>c:\fltk\fl\xutf8.h(33) : fatal error C1083: Cannot open

Is it bad practice to use a C header instead of its C++ equivalent in C++ (e.g. stdio.h instead of cstdio)?

醉酒当歌 提交于 2019-12-01 05:44:00
问题 It seems that a lot of people include example.h instead of cexample in their C++ code. I know that everything in the C++ versions is declared in namespace std, but I'm not aware of any other differences. So why do people use the C headers, and is it okay to do so? 回答1: The difference between the two is that the C headers that C++ imported (by prefixing with c and removing the .h suffix) are in namespace std . This so any call or use of a standard facility is prefixed with std:: , for

How to install/locate R.h and Rmath.h header files?

北城余情 提交于 2019-12-01 03:58:35
I am trying to compile some C code (called rand_beta) in terminal which contains the lines to include R.h and Rmath.h header files using gcc -o rand_beta rand_beta.c so I can then call the code from within R. However, I get the error messages: rand_beta.c:1:15: error: R.h: No such file or directory rand_beta.c:2:19: error: Rmath.h: No such file or directory It seems that these header files which should come installed with R are not on my system. Can someone guide me as to how I can get my computer to find the R header files? Do I need to download them from somewhere? The other answers try to

What does '_IO(…)' mean in C headers in Linux?

白昼怎懂夜的黑 提交于 2019-12-01 03:32:45
I have a Linux standard header file e.g. /usr/src/linux-headers-3.2.0-35/include/linux/usbdevice_fs.h which contain define statements as follows: #define USBDEVFS_SUBMITURB32 _IOR('U', 10, struct usbdevfs_urb32) #define USBDEVFS_DISCARDURB _IO('U', 11) #define USBDEVFS_REAPURB _IOW('U', 12, void *) What does '_IOR', '_IO' and '_IOW' mean? What value is actually given e.g. to USBDEVFS_DISCARDURB ? They define ioctl numbers, based on ioctl function and input parameters. The are defined in kernel, in include/asm-generic/ioctl.h . You need to include <linux/ioctl.h> (or linux/asm-generic/ioctl.h )

How can I quickly search all included header files in a project for a specific symbol?

为君一笑 提交于 2019-12-01 03:27:07
Here's a problem I've had recently that just HAS to be a common pain to others here. I'm working with someone else's legacy C code and need to find where a function or macro was defined. The code #include s a bunch of different standard system libraries in addition to those from the specific project. Is there a tool or technique to quickly find where a specific function, macro, (or other global for that matter) was defined? I tried: grep -R 'function' /usr/lib and other similar *nix/bash-fu with only limited success and lots of annoying chaff to cull. One of you sage coders out there must have

small functions defined in header files: inline or static?

早过忘川 提交于 2019-12-01 02:16:50
I have a number of small functions which are defined in a .h file. It is a small project (now) and I want to avoid the pain of having declarations and definitions separate, because they change all the time. To avoid multiply-defined symbols, I can either have them static or inline . What should be preferred and why? I know it is in general bad practice to define functions in headers. You don't have to mention that in answers, this question is meant technically. Christoph I'd use static inline , but static would work just as well. extern and extern inline are out because you'd get multiple

How can I quickly search all included header files in a project for a specific symbol?

我们两清 提交于 2019-12-01 01:08:18
问题 Here's a problem I've had recently that just HAS to be a common pain to others here. I'm working with someone else's legacy C code and need to find where a function or macro was defined. The code #include s a bunch of different standard system libraries in addition to those from the specific project. Is there a tool or technique to quickly find where a specific function, macro, (or other global for that matter) was defined? I tried: grep -R 'function' /usr/lib and other similar *nix/bash-fu