header-files

Headers include in multiple C files

落花浮王杯 提交于 2019-12-18 16:57:34
问题 I have two files foo.c and bar.c that I compile separately with gcc -c and then link. Both files need the stdio.h and stdlib.h headers. Do I have to include them in both? Doesn't feel a little redundant? Should I maybe use #ifdef? What's the best practice? 回答1: Each C file is a different translation unit . In other words, it is an entire separate program , syntactically complete and correct. Thus, each C file must compile independently of any other C file, and must contain every declaration

Why doesn't C# have header files? Will the namespace take care of everything?

血红的双手。 提交于 2019-12-18 14:14:07
问题 I'm a novice programmer, can anyone tell clearly about the usage of header files and namespaces in C#? Because in C++ I was using ******.h files to read library functions. And when I saw some sample programs in C# they were missing, Can anyone tell me why? I'm using C# to develop customised tool for a mechanical CAD software, there whenever I use the appropriate function to open the file (CAD file), the compiler is giving me an error stating that the function names which I supply are not

Undef a typedef in C++?

时光毁灭记忆、已成空白 提交于 2019-12-18 13:01:24
问题 I am working on a huge project which has one file A.h whose code has a line typedef unsigned __int16 Elf64_Half; Also since I am building on Linux and using dlinfo function, I have to include link.h file in my project. And this is where it creates a conflict because I have two typedefs having the same name Elf64_Half . (Linux link.h includes elftypes.h and it too has: typedef unsigned short Elf64_Half; ). What do I do in such a case? Is the only option I have, to change my typedef in a.h ?

default parameters in .h and .cpp files [duplicate]

做~自己de王妃 提交于 2019-12-18 11:16:27
问题 This question already has answers here : Should C++ function default argument values be specified in headers or .cpp source files? (3 answers) Closed 2 months ago . COMPILER: g++ 4.7.2 Ok. So I am confused about default parameters in .h and .cpp files. It is mentioned in many places( including this site) that default parameters can be added only in .h files and not in .cpp files. However, this code proves it wrong: test1.h #pragma once #include <iostream> using namespace std; class Class{

In what cases we need to include <cassert>?

▼魔方 西西 提交于 2019-12-18 10:27:35
问题 In what cases should we include cassert ? 回答1: In short, don't use it; use <assert.h> . C++11 removed any formal guarantee of a "c...." header not polluting the global namespace. It was never an in-practice guarantee, and now it's not even a formal guarantee. Hence, with C++11 there is no longer any conceivable advantage in using the "c...." header variants, while there is the distinct and clear disadvantage that code that works well with one compiler and version of that compiler, may fail to

C++ Does not name to a type

我们两清 提交于 2019-12-18 09:48:48
问题 This might be an easy question, but I cannot figure out why the compiler it's giving me this error. I have two classes. Agent and Environment. WHen I try to add an object of type Agent in my Environment class I get Agent does not name to a type error. I am including Agent.h in my Environment.h class #ifndef AGENT_H_INCLUDED #define AGENT_H_INCLUDED #include <vector> #include <iostream> #include "Environment.h" using namespace std; class Agent{ public: Agent(bool s); vector<int> getPercept();

Including <termios.h> and <asm/termios.h> in the same project

╄→гoц情女王★ 提交于 2019-12-18 08:46:25
问题 What I want to achieve: I want to set custom baud rate values for some tty* -like UART -mapped terminals. How: The only way I found by far is to use the struct termios2 structure which is located in <asm/termios> header (as mentioned here, first answer). My solution works very well by far, but now I need to use some functions: speed_t cfgetispeed(const struct termios *); int tcdrain(int); int tcflow(int, int); int tcflush(int, int); int tcgetattr(int, struct termios *); pid_t tcgetsid(int);

9Implementing Nuance Speech Recognition on Swift, cannot listen to onResult, onError… events

拟墨画扇 提交于 2019-12-18 07:18:10
问题 I have two parts of my Speech Recon project with Nuance, the .h file of a module (ObjectiveC) and a ViewController (swift). I want to set up a SpeechRecognition object in my swift viewController , and listen to onBegin, onStop... and such methods. The only way to make it compile is to use nil as the delegate parameter to initialize the SpeechRecon object. Obviously this is not good because my onStart... and onFinish functions don´t trigger. I have implemented a protocol to the SKRecogniser

gem install cannot find a header file

我的未来我决定 提交于 2019-12-18 07:17:32
问题 Following along the github README for talib_ruby: sudo port install ta-lib Complete. Next is where the trouble begins. sudo env ARCHFLAGS="-arch PLATFORM" gem install talib_ruby -- --with-talib-include=ABSOLUTE_PATH_TO_TALIB_HEADERS --with-talib-lib=ABSOLUTE_PATH_TO_TALIB_LIBS This install fails I believe because apparently it cannot find the ta_abstract.h file talib.c:2:25: error: ta_abstract.h: No such file or directory . . . many more errors I have included in my .bash_profile file the

Header files won't work in C [closed]

喜夏-厌秋 提交于 2019-12-17 20:32:18
问题 Closed . This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 5 years ago . I'm using Dev-CPP, (but programming in C), and the header files won't work. I've gone to compiler option; directories; c inludes and checked the directory is correct, and it is. The include files are stored in C:\Dev-Cpp\include and that's where it's set to receive them. For example: #include