header-files

Difference Between includes and imports [duplicate]

感情迁移 提交于 2019-12-08 15:44:50
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: What is the difference between #import and #include in Objective-C? What is the difference between #include< > #include" " #import< > #import" " 回答1: The #import directive is an improved version of #include . #import ensures that a file is only ever included once so that you never have a problem with recursive includes. #import "" first check the header in project folder then goes to system library, and the

setting SKScene delegate from viewcontroller, delegate not found

扶醉桌前 提交于 2019-12-08 13:37:15
问题 Trying to open a view controller from an SKScene. Found https://stackoverflow.com/a/20072795/1686319 very helpful, but i get an error when trying to set the delegate from the view controller. No visible @interface for 'SKScene' declares the selector 'setDelegate:' EABMyScene.h #import <SpriteKit/SpriteKit.h> @protocol EABMySceneDelegate <NSObject> -(void)doSomething; @end @interface EABMyScene : SKScene { } @property (nonatomic, weak) id <EABMySceneDelegate> delegate; @end Any idea? Update:

converting png to c header for sdl

吃可爱长大的小学妹 提交于 2019-12-08 11:08:41
问题 I want to say, I have searched in the internet about this topic, but it doesn't apply to my situation. I was doing modifications for a game that uses C and I'm editing the images for use for the game, but the images needs to be converted to c headers to make them work. The game is multi-platform, with builds for Windows and Android via NDK. I've actually accomplished some of the editing with "Using .c/.h images exported with gimp in SDL" as my basis for my solution, using mbin2h, which

Any way in C to forward declare struct in header without having to use pointer in other files?

大兔子大兔子 提交于 2019-12-08 08:09:44
问题 Suppose I have this in list.h: typedef struct list_t list_t; typedef struct list_iter_t list_iter_t; list_iter_t iterator(list_t *list); and then define them in list.c: typedef struct node_t { ... } node_t; struct list_iter_t { node_t *current; // this contains info on whether the iterator has reached the end, etc. char danger; }; struct list_t { ... } list_iter_t iterator(list_t *list) { list_iter_t iter; ... return iter; } Is there anything I can do aside from including the struct

Including header files when there's no implementation file?

霸气de小男生 提交于 2019-12-08 07:54:12
问题 I was looking at the source code for ncmpcpp, and I saw this. #include <mpd/client.h> Inside that file are functions which are used by ncmpcpp. But those are just the headers. Don't the cpp files have to exist somewhere as well? I couldn't find them in the same directory. Where are they? Also, when something that's included is surrounded by < and >, how do I know where to look? 回答1: If it's a third-party library, most likely the source code won't be included. Nor is it needed. All symbols

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

守給你的承諾、 提交于 2019-12-08 07:02:25
问题 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

Vim script for automatic function insertion

孤者浪人 提交于 2019-12-08 04:55:32
问题 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... 回答1: The task is not that trivial -- if we want to correctly report the scope of the

Check if a file is a specific type in C

橙三吉。 提交于 2019-12-08 04:55:22
问题 I'm writing my first C program, though I come from a C++ background. I need to iterate through a directory of files and check to see if the file is a header file, and then return the count. My code is as follows, it's pretty rudimentary I think: static int CountHeaders( const char* dirname ) { int header_count = 0; DIR* dir_ptr; struct dirent* entry; dir_ptr = opendir( dirname ); while( ( entry = readdir( dir_ptr ) ) ) { if ( entry->d_type == DT_REG ) { //second if statement to verify the

Objective c - import .m and .h file - what does it do

a 夏天 提交于 2019-12-08 03:54:23
问题 In objective c, what actually happened when you say #import "MyClass.h"? (Is the compiler copying something for you?) In MyClass.m file, if I #import "UsefulClass.h" , this means that UsefulClass becomes available under this file and I can create object and send message to an instance of it. In myClass.m file, I have to #import "MyClass.h" , this sounds like linking my implementation file to its header (called base file?), which feels quite different from what the first one does. So does

Static analysis of header inclusion in C++

岁酱吖の 提交于 2019-12-08 03:43:30
问题 It seems that often I find that my code when moving either from one linux installation to another or from one unix to another, I find that I've missed including certain header files. This tends to become annoying when you give the source to someone else expecting them to be able to compile it just fine, only for it to fail because of missing header file includes. Are there any static analysis tools that can detect headers that should be explicitly included where they're currently seem to be