In my project I cannot find Prefix.pch file so I create new one, and Build Setting -- prefix header add the file path and name in it projectdir/projectname-Prefix.pch
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#import <CoreData/CoreData.h>
#define APP_FONT(fontSize) [UIFont systemFontOfSize:fontSize]
#endif
I can set font without any error warning label.font = APP_FONT(18);
However it crash at running time, APP_FONT(18) returns nil.
It is no problem run on ios8
Related
I have created a .c and a .h file with the same name. The .c file includes the header file and a main.c file includes both.
I want to put this statement in the header:
#ifndef TIMEOUT
#error TIMEOUT not set
#endif
To force the user to specify a TIMEOUT when compiling. The problem is that CLion says gives a red line under 'error' and says 'TIMEOUT not set'.
The weird thing is that up until now all my projects have used this. The difference is that the variables behind '#ifndef' and '#define' etc. have become dark green, whereas in my previous projects these were always grey.
Have I changed a setting to something not correct? Making a new project does not solve this problem.
Let me know if I should add screenshots, thanks in advance!
Our company's main project has several preprocessor constants that must be adjusted for different customers. When the program was first written, it was considered enough to merely to build Debug and Release versions of the code. It never occurred to anyone until I got tired of rebuilding the project all the time that we could use preprocessor constants and project settings to build into different folders for each customer.
But we have one ActiveX DLL our project needs that has to be in a specific folder. (Making that an ActiveX DLL was yet another in the long list of bad decisions my company made on this project.) That DLL is #imported into the code using this:
#ifdef _DEBUG
#import "..\Debug\CapsHelper.dll" no_namespace
#else
#import "..\Release\CapsHelper.dll" no_namespace
#endif
I am currently trying to build for a customer named Algoma. So, I want to create a preprocessor constant named CUSTOMER that would contain "Alcoma" and then tell the compiler to import from a folder named either "Debug Alcoma" or "Release Alcoma". How would I do that?
I tried this:
#define CUSTOMER Alcoma
#ifdef _DEBUG
#import "..\Debug " #CUSTOMER "\CapsHelper.dll" no_namespace
#else
#import "..\Release " #CUSTOMER "\CapsHelper.dll" no_namespace
#endif
But that didn't work. It didn't work without the # before CUSTOMER either.
I presume you're using MSVC, and I haven't tested this solution with it. But it should work:
#define XSTR(X) #X
#define STR(X) XSTR(X)
#ifdef _DEBUG
#import STR(..\Debug CUSTOMER\CapsHelper.dll) no_namespace
#else
#import STR(..\Release CUSTOMER\CapsHelper.dll) no_namespace
#endif
The basic issue with your attempt (aside from the fact in standard C/C++, # can only occur inside a macro expansion) is that while #include (and, I suppose, #import) will macro-expand their argument, they will not perform string concatenation. So the stringify operator needs to be applied to the entire string.
I am creating a react app with the create-react-app and I have tried to implement SASS pre-processor by following these steps over here. So everything went well and I have developed already some parts of my application. But for a really weird reason, I now got a error on compiling after already 2 days of development, without any reason I can imagine.
{
"status": 1,
"file": "/Users/glenngijsberts/Documents/Development/toggle/src/components/sass/assets.scss",
"line": 2,
"column": 9,
"message": "Undefined variable: \"$primary\".",
"formatted": "Error: Undefined variable: \"$primary\".\n on line 2 of src/components/sass/assets.scss\n>> \tcolor: $primary;\n --------^\n"
}
So the main problem is that I get now a compile error because my assets.scss can't access the variables. Assets is imported in my App.scss which also imported variables.scss.
In my App.scss file
//Import SCSS
#import "./sass/vars.scss";
#import "./sass/popup.scss";
#import "./sass/assets.scss";
#import "./sass/utils.scss";
#import "./sass/modal.scss";
#import "./sass/dropdown.scss";
#import "./sass/visualLine.scss";
#import "./sass/dashboard.scss";
#import "./sass/tabs.scss";
#import "./sass/projects.scss";
#import "./sass/colors.scss";
What is working is:
assets.scss
//Import SCSS
#import "vars.scss";
span.brand {
color: $primary;
}
But ofcourse, I don't like to include that vars file on every scss file where I want to use a scss variable. I am not used to it either (when using just sass files with a regular webpack project).
You have to put "_" to beginning name of every file you want to globally import. So your vars.scss would be _vars.scss. Sounds weird, but works.
If it won't help, rename your files to *.sass and use sass syntax. It is simplier and would work on 100%.
I have a file called assert.h which defines several assertion macros. The project is called Core and lives in a folder with the same name. However, this file lives in Core/hul, which is a submodule of the project that implements some abstract utilities. Here's an excerpt of the file:
#if defined(HUL_DEBUG)
# if defined(HUL_TEST)
# define HUL_ASSERT(e) HUL_TEST_ASSERT(e)
# else
# include <assert.h>
# define HUL_ASSERT(e) assert(e)
# endif
#else
# define HUL_ASSERT(e) /* empty, do nothing */
#endif
As you can see, when HUL_TEST is defined assertion macros expand to a unit test assertion callback. That works fine. When compiling for release (e.g. HUL_DEBUG is not defined) it does nothing. Also fine. When compiling for debug (without testing), it includes the system's assert.h and defines a macro that expands to assert. Everything OK so far.
The problem is that regardless of including <hul/assert.h> or <assert.h> it's always hul/assert.h that is included, which is not what I want. This is one of the reasons that hul/assert.h is qualified under the hul folder.
The obvious first thing to check is Other C Flags and Header Search Paths. But the later is empty and the former is as follows:
-I../../include/Core
-I../../test/include/Core
-I../../test/include
As you can see, Core/hul is not included, so #include <assert.h> should not resolve to hul/assert.h. The question is, why does it? Am I missing some configuration?
Note: of course I could change the file's name, but I rather understand why this is happening. This framework will still grow immensely in number of files and I don't want to be worrying about this kind of conflicts.
set USE_HEADERMAP = NO. When set to YES, XCode uses a dictionary that maps a header file name to a path where to find in order to speed up compilation. So regardless where you place your header file, if it has found his way into this map it will be found forth on.
Another way would be to use absolute paths for all user header files, e.g. #include "./assert.h" (which should give you an error if the file is not located directly in the project directory or any manually defines user header search path).
Hope it helps;
Eg: I want to import a file called #import 's-grid-settings' in multiple different stylus files. Is this a bad idea?
It depends :)
Stylus have two ways of “importing” other stylus documents: via #import and via #require.
The difference is that #import would import the file each time, while #require would do this only once.
#require this way could be useful to share the settings and/or some common stuff like placeholders etc. between multiple stylus files in a such way those files could be either compiled each by itself or as a bundle. If the #import was used in this case, it would include all its stuff every time it was called, while #require would do this only once at the first call.
So, the answer to your question would depend on what is there inside your file.