header-files

Memory allocation in header files

 ̄綄美尐妖づ 提交于 2020-01-15 11:55:06
问题 The company I'm working for have development rules for C development on embedded target. One is : It is recommended to not allocate any storage space in the header files. I'm not sure what it means, the person who wrote it is not around and the other developers don't really care, so I am asking here. What I understand is that I shouldn't declare variables in a header files, so something like that would be discouraged in a .h : int myVar; static char myOtherVar; What I don't understand is what

Using (relative) paths to shortcut in include statements in C++

一笑奈何 提交于 2020-01-14 14:04:27
问题 I started coding in C++ few days ago. I am using windows as my OS for writing code. I have been keeping all of my "well-written" codes in a single location. Now, I am working on a project that requires the use of those codes. So, I planned to include those files that I require as header files in my project. However, to make my project "self-contained", I created shortcuts of those folders that I require and kept them in the source folder of my new project and decided to use relative paths to

Using (relative) paths to shortcut in include statements in C++

浪子不回头ぞ 提交于 2020-01-14 14:03:53
问题 I started coding in C++ few days ago. I am using windows as my OS for writing code. I have been keeping all of my "well-written" codes in a single location. Now, I am working on a project that requires the use of those codes. So, I planned to include those files that I require as header files in my project. However, to make my project "self-contained", I created shortcuts of those folders that I require and kept them in the source folder of my new project and decided to use relative paths to

QT undefined reference errors when trying to compile

六月ゝ 毕业季﹏ 提交于 2020-01-11 08:41:51
问题 I added a class IcecastServer to my QT-project, added the header-file to the pro file and added some code. Everytime I compile it the following errors occur: release/icecastserver.o:icecastserver.cpp:(.text+0x39): undefined reference to _imp___ZN10QTcpServerC1EP7QObject' release/icecastserver.o:icecastserver.cpp:(.text+0x50): undefined reference to imp ZN12QHostAddressC1ENS_14SpecialAddressE' release/icecastserver.o:icecastserver.cpp:(.text+0x68): undefined reference to _imp__

Go/Golang Cross-Compile from Mac to Windows: fatal error: 'windows.h' file not found

会有一股神秘感。 提交于 2020-01-11 07:58:10
问题 Summary : when I try cross-compiling a .go source file that includes a C file somewhere in the file chain, targeting Windows AMD64 from a Mac host, I get: /usr/local/go/src/runtime/cgo/gcc_windows_amd64.c:8:10: fatal error: 'windows.h' file not found Purely Go code seems to cross compile without error; is there a way to get the proper header files for cross compilation when C files are involved? More details : I installed LiteIDE on my Mac for working on some .go projects, and LiteIDE makes

Use the keyword class as a variable name in C++

浪子不回头ぞ 提交于 2020-01-11 01:00:30
问题 I am having trouble writing C++ code that uses a header file designed for a C file. In particular, the header file used a variable name called class: int BPY_class_validate(const char *class_type, PyObject *class, PyObject *base_class, BPY_class_attr_check* class_attrs, PyObject **py_class_attrs); This works in C as class isn't taken as a keyword, but in C++, class is. So is there anyway I can #include this header file into a c++ file, or am I out of luck? Thank you. 回答1: try something like

Why shouldn't I put “using namespace std” in a header?

烈酒焚心 提交于 2020-01-09 11:56:09
问题 Someone once hinted that doing this in a header file is not advised: using namespace std; Why is it not advised? Could it cause linker errors like this: (linewrapped for convenience) error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >:: ~basic_string<char,struct std::char_traits<char>,class std::allocator<char> > (void)" (??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ) already defined in tools.lib

Missing header files from an shared C++ project

拥有回忆 提交于 2020-01-07 06:42:32
问题 I have downloaded an .NET solution, which is contains 2 C# and 1 C++ project. When I build the solution, the Error List says: Error 1 error C1083: Cannot open include file: 'libavformat/avformat.h': No such file or directory C:\Users\Dinh\Downloads\TestOnvif-master\TestOnvif-master\FFmpegRTSPCppCLR\FFmpegMedia.cpp 19 1 TestFFmpegLib Actually, I see an folder in solution directory named lib , it containts all *.h files that the C++ project need to use. Som, How to make the C++ project see

Missing header files from an shared C++ project

谁都会走 提交于 2020-01-07 06:41:10
问题 I have downloaded an .NET solution, which is contains 2 C# and 1 C++ project. When I build the solution, the Error List says: Error 1 error C1083: Cannot open include file: 'libavformat/avformat.h': No such file or directory C:\Users\Dinh\Downloads\TestOnvif-master\TestOnvif-master\FFmpegRTSPCppCLR\FFmpegMedia.cpp 19 1 TestFFmpegLib Actually, I see an folder in solution directory named lib , it containts all *.h files that the C++ project need to use. Som, How to make the C++ project see

Trying to use a class in one header file in another header file

自作多情 提交于 2020-01-07 04:30:32
问题 I have a weightedDirectedGraph class and a vertex class in their own header file, weightedDirectedGraph.h. This is it: #ifndef GRAPH #define GRAPH #include <iostream> #include <string> #include <vector> #include <list> #include "minHeapVertex.h" using namespace std; class vertex { public: string data; list<vertex *> neighbors; bool known; int distance, id; vertex * path; vertex(string x) { data = x; } }; class weightedDirectedGraph { private: list<vertex *> vertexList; vector<vector<int> >