preprocessor

Preprocessor “invalid integer constant expression” comparing int to double

久未见 提交于 2021-02-05 04:54:03
问题 Somewhere in my code, I have preprocessor definition #define ZOOM_FACTOR 1 In another place I have #ifdef ZOOM_FACTOR #if (ZOOM_FACTOR == 1) #define FONT_SIZE 8 #else #define FONT_SIZE 12 #endif #else #define FONT_SIZE 8 #endif The problem is when I change ZOOM_FACTOR value to floating point value, for example 1.5 , I'm getting compile error C1017: invalid integer constant expression . Does anyone know why am I getting this error and is there any way to make a comparison between integer and

Preprocessor “invalid integer constant expression” comparing int to double

心已入冬 提交于 2021-02-05 04:51:04
问题 Somewhere in my code, I have preprocessor definition #define ZOOM_FACTOR 1 In another place I have #ifdef ZOOM_FACTOR #if (ZOOM_FACTOR == 1) #define FONT_SIZE 8 #else #define FONT_SIZE 12 #endif #else #define FONT_SIZE 8 #endif The problem is when I change ZOOM_FACTOR value to floating point value, for example 1.5 , I'm getting compile error C1017: invalid integer constant expression . Does anyone know why am I getting this error and is there any way to make a comparison between integer and

Preprocessor “invalid integer constant expression” comparing int to double

不羁岁月 提交于 2021-02-05 04:47:39
问题 Somewhere in my code, I have preprocessor definition #define ZOOM_FACTOR 1 In another place I have #ifdef ZOOM_FACTOR #if (ZOOM_FACTOR == 1) #define FONT_SIZE 8 #else #define FONT_SIZE 12 #endif #else #define FONT_SIZE 8 #endif The problem is when I change ZOOM_FACTOR value to floating point value, for example 1.5 , I'm getting compile error C1017: invalid integer constant expression . Does anyone know why am I getting this error and is there any way to make a comparison between integer and

How do I use a preprocessor macro inside an include?

生来就可爱ヽ(ⅴ<●) 提交于 2021-02-04 12:22:06
问题 I am trying to build freetype2 using my own build system (I do not want to use Jam, and I am prepared to put the time into figuring it out). I found something odd in the headers. Freetype defines macros like this: #define FT_CID_H <freetype/ftcid.h> and then uses them later like this: #include FT_CID_H I didn't think that this was possible, and indeed Clang 3.9.1 complains: error: expected "FILENAME" or <FILENAME> #include FT_CID_H What is the rationale behind these macros? Is this valid C/C+

How do I concatenate two string macros in C?

不打扰是莪最后的温柔 提交于 2021-01-28 01:06:47
问题 I am trying to implement VERSION macro for my program, that is to be changed under certain circumstances. macro VERSION is defined via Makefile (git info is put there) and is a string. Now I have a set of #define'd switches and I want VERSION to reflect which of them are on. This looks now like the follows (main.h): #define COMPLEX_DEPOSITION // This is switch. later in code it is used in #ifdef...#endif construction. #ifdef COMPLEX_DEPOSITION #define CD "_COMP_DEP" // this is the string I

How to check release / debug builds using cfg in Rust?

此生再无相见时 提交于 2021-01-20 17:00:08
问题 With the C pre-processor it's common to do, #if defined(NDEBUG) // release build #endif #if defined(DEBUG) // debug build #endif Cargo's rough equivalents are: cargo build --release for release. cargo build for debug. How would Rust's #[cfg(...)] attribute or cfg!(...) macro be used to do something similar? I understand that Rust's pre-processor doesn't work like C's. I checked the documentation and this page lists some attributes. (assuming this list is comprehensive) debug_assertions could

Scala conditional compilation

自古美人都是妖i 提交于 2021-01-20 12:23:06
问题 I'm writing a Scala program and I want it to work with two version of a big library. This big library's version 2 changes the API very slightly (only one class constructor signature has an extra parameter). // Lib v1 class APIClass(a: String, b:Integer){ ... } // Lib v2 class APIClass(a: String, b: Integer, c: String){ ... } // And my code extends APIClass.. And I have no #IFDEF class MyClass() extends APIClass("x", 1){ // <-- would be APIClass("x", 1, "y") in library v2 ... } I really don't

Cyclical Loop Between OneHotEncoder and KNNImpute in Scikit-learn

强颜欢笑 提交于 2021-01-04 05:50:31
问题 I'm working with a really simple dataset. It has some missing values, both in categorical and numeric features. Because of this, I'm trying to use sklearn.preprocessing.KNNImpute to get the most accurate imputation I can. However, when I run the following code: imputer = KNNImputer(n_neighbors=120) imputer.fit_transform(x_train) I get the error: ValueError: could not convert string to float: 'Private' That makes sense, it obviously can't handle categorical data. But when I try to run

Cyclical Loop Between OneHotEncoder and KNNImpute in Scikit-learn

你离开我真会死。 提交于 2021-01-04 05:49:44
问题 I'm working with a really simple dataset. It has some missing values, both in categorical and numeric features. Because of this, I'm trying to use sklearn.preprocessing.KNNImpute to get the most accurate imputation I can. However, when I run the following code: imputer = KNNImputer(n_neighbors=120) imputer.fit_transform(x_train) I get the error: ValueError: could not convert string to float: 'Private' That makes sense, it obviously can't handle categorical data. But when I try to run

Why is there an additional pair of curly braces on the Inno Setup Preprocessor:#emit page?

|▌冷眼眸甩不掉的悲伤 提交于 2020-12-06 16:51:19
问题 I've been looking through Inno Setup documentation and found this: (https://jrsoftware.org/ispphelp/index.php?topic=expressions) Filename: "file2.ext"; DestDir: {{#MyDestDir}} Why do we need to use an additional pair of curly braces here? Mustn't we type it like this instead DestDir: "{#MyDestDir}" ? 来源: https://stackoverflow.com/questions/63036551/why-is-there-an-additional-pair-of-curly-braces-on-the-inno-setup-preprocessor