preprocessor

how to avoid name conflicts coming from #define in C? (or C++)

ⅰ亾dé卋堺 提交于 2020-01-17 06:04:40
问题 This should be very basic question, and I can avoid this situation by changing some names but I think maybe there is something I am missing here. I have made a simplest code for this problem. conv.h : 1 struct convpar_ { 2 int K; 3 } convpar_; test.c : 1 #include <stdio.h> 2 #include "conv.h" 3 4 #define K 7 5 6 typedef struct convpar_ convpar; 7 8 void func1(convpar cp) 9 { 10 printf("cp.K = %d\n", cp.K); 11 } 12 13 main() 14 { 15 convpar cp = {K}; 16 17 func1(cp); 18 } If I do cc test.c -o

how to avoid name conflicts coming from #define in C? (or C++)

一曲冷凌霜 提交于 2020-01-17 06:03:10
问题 This should be very basic question, and I can avoid this situation by changing some names but I think maybe there is something I am missing here. I have made a simplest code for this problem. conv.h : 1 struct convpar_ { 2 int K; 3 } convpar_; test.c : 1 #include <stdio.h> 2 #include "conv.h" 3 4 #define K 7 5 6 typedef struct convpar_ convpar; 7 8 void func1(convpar cp) 9 { 10 printf("cp.K = %d\n", cp.K); 11 } 12 13 main() 14 { 15 convpar cp = {K}; 16 17 func1(cp); 18 } If I do cc test.c -o

How to remove not useful elements from a dataset

自作多情 提交于 2020-01-15 12:17:12
问题 I have a dataset, and it look like the following: {0: {"address": 0, "ctag": "TOP", "deps": defaultdict(<class "list">, {"ROOT": [6, 51]}), "feats": "", "head": "", "lemma": "", "rel": "", "tag": "TOP", "word": ""}, 1: {"address": 1, "ctag": "Ne", "deps": defaultdict(<class "list">, {"NPOSTMOD": [2]}), "feats": "_", "head": 6, "lemma": "اشرف", "rel": "SBJ", "tag": "Ne", "word": "اشرف"}, I want to remove "deps":...? from this dataset. I tried this code but does not work, because the value of

Pipeline doesn't work with Label Encoder

偶尔善良 提交于 2020-01-15 09:23:07
问题 I do as below import pandas as pd from sklearn import preprocessing import sklearn from sklearn.pipeline import Pipeline df = pd.DataFrame({'c':['a', 'b', 'c']*4, 'd': ['m', 'f']*6}) encoding_pipeline =Pipeline([ ('LabelEncoder', preprocessing.LabelEncoder()) ]) encoding_pipeline.fit_transform(df) and full Traceback TypeError Traceback (most recent call last) <ipython-input-7-0882633ccf59> in <module>() ----> 1 encoding_pipeline.fit_transform(df) C:\Program Files\Anaconda3\lib\site-packages

Solaris and Preprocessor Macros

倖福魔咒の 提交于 2020-01-14 18:49:34
问题 Would someone post the results of cpp -dM < /dev/null from a Solaris 10 or above system? I'm having trouble locating what preprocessor macros are typically defined. Solaris documentation does not discuss it in detail [1], [2], and Google is not being very helpful. Thanks in advance. 回答1: Solaris 11.1 #define __DBL_MIN_EXP__ (-1021) #define __FLT_MIN__ 1.17549435e-38F #define __CHAR_BIT__ 8 #define __WCHAR_MAX__ 2147483647 #define __DBL_DENORM_MIN__ 4.9406564584124654e-324 #define __FLT_EVAL

Solaris and Preprocessor Macros

六月ゝ 毕业季﹏ 提交于 2020-01-14 18:48:30
问题 Would someone post the results of cpp -dM < /dev/null from a Solaris 10 or above system? I'm having trouble locating what preprocessor macros are typically defined. Solaris documentation does not discuss it in detail [1], [2], and Google is not being very helpful. Thanks in advance. 回答1: Solaris 11.1 #define __DBL_MIN_EXP__ (-1021) #define __FLT_MIN__ 1.17549435e-38F #define __CHAR_BIT__ 8 #define __WCHAR_MAX__ 2147483647 #define __DBL_DENORM_MIN__ 4.9406564584124654e-324 #define __FLT_EVAL

Java preprocess phase

烂漫一生 提交于 2020-01-14 10:43:07
问题 I'm writing a Java application that needs a lot of static data that is stored in many enum types. Since I would like an user-friendly way to customize this data using for example xml or json files but I'm not allowed to do it directly with enums I was looking for a way to elegantly do it. Maybe a good solution would be to have a separate java program that reads the xml files and produces the java sources that are then compiled with the remaining part of the sources. My doubs is how to

Variadic function without nil termination

岁酱吖の 提交于 2020-01-14 04:49:10
问题 I am trying to create a method like the following: - (void)setCondition:(NSString *)format, ... NS_FORMAT_FUNCTION(1,2); But since I'm not great with preprocessor, I hit an issue that I have fixed in the following code snippet, but I'd like to know if there's not cleaner way to achieve what I want which is to stop after the provided arguments + (CRCondition *)conditionWithFormat:(NSString *)format,... { CRCondition *condition = [[CRCondition alloc] init]; NSArray *conditionSliced = [condition

Preprocessor macro for Apple Watch?

随声附和 提交于 2020-01-12 13:49:06
问题 I was looking at Apple's Lister (for Apple Watch, iOS, and OS X) sample. The sample performs a test for iOS and OS X: #import <TargetConditionals.h> #if (TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR) @import ListerKit; #elif TARGET_OS_MAC @import ListerKitOSX; #endif However, there is no test for TARGET_OS_WATCH or similar. Grepping for watch in TargetConditionals.h delivers no hits: $ cat /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer /SDKs/iPhoneOS7.1.sdk

Organize Java Imports programmatically

自闭症网瘾萝莉.ら 提交于 2020-01-06 08:09:39
问题 I have written a custom build script for my android app. I included some "easy" preprocessing, so I can define comments like //#ifdef something ... CODE //#endif and get rid of the Code part if configured so. The Problem is, that after preprocessing I don't need some modules anymore, so I leave them out. What remains is the import statement for that module which bites me, if I want to build the app finally. I'm searching for a way within my preprocessing, to organize the java Imports inside