header-files

Where various variable and method types should be placed in a header

给你一囗甜甜゛ 提交于 2019-11-29 12:51:14
I've noticed that I get compilation errors if I place certain declarations in certain places in my header file. I've put comments into the code as to where I think certain things go; are they correct? @interface Level : CCNode { //Instance variables? PlayBackgroundLayer* playBGLayer; PlayUILayer* playUILayer; PlayElementLayer* playElementLayer; } //Static methods? +(void) InitLevel: (int) levelNumber; +(Level*) GetCurrentLevel; //Property declarations for instance variables? @property (nonatomic, retain) PlayBackgroundLayer* playBGLayer; @end //Static variables? Level* currentLevel;

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

邮差的信 提交于 2019-11-29 12:45:18
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 file, and extended my ViewController class to SKReconDelegate... but if I use "self" as a delegate to

When is it useful to include the same header multiple times in one file? [duplicate]

戏子无情 提交于 2019-11-29 10:08:57
This question already has an answer here: Is there a case where including the same header twice is actually helpful? 6 answers I was reading about multiple inclusions of the same header in one file, and found an interesting statement ( link ): There are a couple of tricks with header files were you deliberately include it multiple times (this does actually provide a useful feature). I understand that those tricks are probably undesired and confusing in real-world projects (especially since people take precautions against multiple inclusions, like include guards and #pragma once ). But still,

“XXX-Swift.h” file not found in test project

两盒软妹~` 提交于 2019-11-29 07:40:08
I'm trying to call a method of a NSObject subclass I have in the let's say "main" project within a method of a XCTestCase subclass in the test project. The NSObject subclass of the main project imports the "XXX-Swift.h" header file (I'm mixing Swift and Objective-C code). All works fine when I run the main project, but when I run the tests calling an object of that subclass, I get an error saying that the Swift header file in the import is not found. I guess I'm missing some settings in the test target, but I don`t find which... what should I check? Or what should I do to solve this? Sohil R.

What is the difference between header file and namespace?

南楼画角 提交于 2019-11-29 06:59:40
问题 I want to know the exact difference between Header file (as in MyHeader.hpp) and a namespace in c++ ? 回答1: Header files are actual files - stored in the file system, referenced by file name, and #include 'd in other files (at least, in C/C++ or other languages using the M4 macro preprocessor). Header files typically group pieces of code that are all interdependent parts of the same specific item together. For instance, a game might have a header file for all of its graphics rendering.

Why do I see THROW in a C library?

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-29 04:38:42
问题 When I do: less /usr/include/stdio.h (which is only a C library - nothing to do with C++) I see __THROW after quite a few function declarations. Also, comments above a few functions say that 'This function is a possible cancellation point and therefore not marked with __THROW ' What is all this for? throw is meant to be for exception handling...but as far as I know, C doesn't provide any support for it. Please explain. 回答1: This header is likely shared between the C and C++ compiler for that

Why is there no multiple definition error when you define a class in a header file?

核能气质少年 提交于 2019-11-29 04:02:52
I'm not sure if I asked the question correctly, but let me explain. First, I read this article that explains the difference between declarations and definitions: http://www.cprogramming.com/declare_vs_define.html Second, I know from previous research that it is bad practice to define variables and functions in a header file, because during the linking phase you might have multiple definitions for the same name which will throw an error. However, how come this doesn't happen for classes? According to another SO answer ( What is the difference between a definition and a declaration? ), the

Xcode - Importing different header file with same name based on Target

断了今生、忘了曾经 提交于 2019-11-29 03:55:54
问题 I have a project with multiple targets each of which builds a pretty similar versions of the app but with different images assets and plists. For plists/images that's fine but I use the ShareKit and Appirater frameworks which have header files with #defines for their config. For each version I believe need to import a different version of this header file, as the config is different for each app built by each target. So target A has SHConfig.h and target B has a DIFFERENT SHConfig.h I could

Placing header files in a subdirectory of /usr/include with automake?

前提是你 提交于 2019-11-29 03:05:57
问题 If I write a library, and have header files for development included, and have a src/Makefile.am like this: AM_CFLAGS = -std=c99 -Wall -Werror -Os lib_LTLIBRARIES = libmylibrary.la libmylibrary_la_SOURCES = a.c b.c include_HEADERS = a.h b.h Everything works nicely. However, a.h and b.h are installed directly under /usr/include (or /usr/local/include ). What should I do to get them installed, in a subdirectory specific to my library, e.g. /usr/include/mylibrary ? 回答1: As well as pkginclude

CMake - dependencies (headers) between apps/libraries in same project

橙三吉。 提交于 2019-11-29 02:21:12
问题 I have the following project structure: CMakeLists.txt lib1/CMakeLists.txt and all cpp and header files of the lib lib2/CMakeLists.txt and all cpp and header files of the lib app/CMakeLists.txt and all cpp and header files of the app The main CMakeLists.txt looks like: PROJECT( ${PROJECT_NAME} ) add_subdirectory(lib1) add_subdirectory(lib2) add_subdirectory(app) The lib1/CMakeLists.txt looks eg like (stripped): SET(SOURCE file.cpp ) SET(HEADERS some_lib_header.h ) add_library( lib1 ${SOURCE}