header-files

“Multiple include guards may be useful for” what, exactly?

倾然丶 夕夏残阳落幕 提交于 2019-12-07 05:11:48
问题 I've been playing around with the -H option of gcc, which prints out information about direct and indirect includes in C and C++ compilation (relevant section of the gcc manual). As part of the output there's a section "Multiple include guards may be useful for:", which lists a number of project and system headers. What does this mean, how is this list determined, and why is it saying "Multiple" include guards may be useful? (I'm familiar with the general concept of include guards, and why

G++ compiler error - Synthesized method first required here

你。 提交于 2019-12-07 01:40:42
问题 Here's the error: In file included from /usr/lib/gcc/x86_64-redhat-linux/4.4.6/../../../../include/c++/4.4.6/ios:39, from /usr/lib/gcc/x86_64-redhat-linux/4.4.6/../../../../include/c++/4.4.6/ostream:40, from /usr/lib/gcc/x86_64-redhat-linux/4.4.6/../../../../include/c++/4.4.6/iostream:40, from date.h:15, from date.cpp:13: /usr/lib/gcc/x86_64-redhat-linux/4.4.6/../../../../include/c++/4.4.6/bits/ios_base.h: In copy constructor ‘std::basic_ios<char, std::char_traits<char> >::basic_ios(const std

CPP | .h files (C++)

試著忘記壹切 提交于 2019-12-07 00:41:32
问题 I was just wondering what the difference between .cpp and .h files is? What would I use a header file (.h) for and what would I use a cpp file for? 回答1: In general, and it really could be a lot less general: .h (header) files are for declarations of things that are used many times, and are #include d in other files .cpp (implementation) files are for everything else, and are almost never #include d 回答2: Technically, there is no difference. C++ allows you to put your code in any file, with any

Make doesn't rebuild headers when changed

跟風遠走 提交于 2019-12-06 23:41:44
问题 I have a project for which I regularly modify headers and when I do so, and forget to make clean then make , I get all sorts of weird behavior. I'm currently using Qt Creator as my IDE, but I've seen this happen on a Qt-independent project. My project is getting fairly large, and having to rebuild every time I make a header change is becoming unproductive. Any thoughts? For future reference: If using the QMake system: DEPENDPATH += . \ HeaderLocation1/ \ HeaderLocation2/ \ HeaderLocation2

Is it unspecified whether a standard library header includes arbitrary headers?

馋奶兔 提交于 2019-12-06 22:20:40
问题 There is a claim in Which headers in the C++ standard library are guaranteed to include another header?: The C++ standard library headers may include each other in unspecified ways, so programmers generally shouldn't depend on one header including another. [...] In practice this tends to be the case. For example, <iostream> may include <string> , in other cases you need to include <string> explicitly. However, I can't seem to find where in N4140 this is the case. I've looked in: §2.9 [lex

Objective C: Should I assign the variable AND create a property or is just one of them enough?

怎甘沉沦 提交于 2019-12-06 20:47:43
I have got a header file (.h) and I want to declare name but all these ways work the same I think because I haven't seen any difference with functionality. Could you tell me what the difference is between: This with both declarations: @interface someClass : UIViewController { NSString *name; } @property (nonatomic, copy) NSString *name; @end Without variable: @interface someClass : UIViewController { } @property (nonatomic, copy) NSString *name; @end Or Without property: @interface someClass : UIViewController { NSString *name; } @end @interface someClass : UIViewController { NSString *name; }

CLion doesn't resolve headers from external library

非 Y 不嫁゛ 提交于 2019-12-06 19:44:59
问题 Some time ago I started a big header library in C++1x using XCode. The current layout of the library is () something like (partial output from ls -R sponf ) sponf/sponf: ancestors sponf.h sponf_utilities.h categories sponf_children.h utilities children sponf_macros.h sponf/sponf/ancestors: function.h meter.h set.h simulation.h sponf/sponf/categories: free_space.h prng.h random_distribution.h series.h sponf/sponf/children: distributions histogram.h random simulations meters numeric series

Declaring variables in header files C++ [duplicate]

扶醉桌前 提交于 2019-12-06 18:00:43
问题 This question already has answers here : What should go into an .h file? (12 answers) Closed 3 years ago . I'm trying to create a simple program that takes input from the user in C++ using good programming practices. It consists of Input.hpp, Input.cpp and main.cpp. I keep getting a multiple definition error even though I am using ifndef to prevent that. Input.hpp #ifndef Input_HPP #define Input_HPP #include <string> #include <vector> using namespace std; vector<string> Get_Input(); vector

Python's easy_install and custom header/library location

扶醉桌前 提交于 2019-12-06 16:09:26
问题 I am trying to install adns-python using linux and had to recompile adns with some special options, so I can't seem to use easy_install <tarball> as I normally would (py26_default)[mpenning@localhost src]$ easy_install adns-python-1.2.1.tar.gz Processing adns-python-1.2.1.tar.gz Running adns-python-1.2.1/setup.py -q bdist_egg --dist-dir /tmp/easy_install-9cVl4i/adns-python-1.2.1/egg-dist-tmp-vvO8Ms adnsmodule.c:10:18: error: adns.h: No such file or directory adnsmodule.c:31: error: expected

Vim script for automatic function insertion

纵然是瞬间 提交于 2019-12-06 15:31:00
Say I have a class evilLord declared in the file evil_lair.hh and is implemented in the file evil_lair.cc . Now, I want to add the function bool minionDo(std::string command) . Is there any script which will put the declaration and empty function definition in the respective files automatically? I am using c-support vim-plugin which I find useful. Maybe this can be added as a functionality to this script... The task is not that trivial -- if we want to correctly report the scope of the function. I've already done the work in my :GOTOIMPL (and :MOVEIMPL ) command, from my lh-cpp ftplugin suite