declaration

Difference between int32, int, int32_t, int8 and int8_t

我只是一个虾纸丫 提交于 2019-11-28 15:20:27
I came across the data type int32_t in a C program recently. I know that it stores 32 bits, but don't int and int32 do the same? Also, I want to use char in a program. Can I use int8_t instead? What is the difference? To summarize: what is the difference between int32, int, int32_t, int8 and int8_t in C? Jerry Coffin Between int32 and int32_t , (and likewise between int8 and int8_t ) the difference is pretty simple: the C standard defines int8_t and int32_t , but does not define anything named int8 or int32 -- the latter (if they exist at all) is probably from some other header or library

Component is part of the declaration of 2 modules

二次信任 提交于 2019-11-28 15:20:23
I try to build an ionic 2 app. When I try the app in the browser with ionic serve or launch it on an emulator everything works fine. But when I try to build it every time the error ionic-app-script tast: "build" Error Type AddEvent in "PATH"/add.event.ts is part of the declarations of 2 modules: AppModule in "PATH"/app.modules.ts and AddEvent in "PATH"/add-event.module.ts. Please consider moving AddEvent in "PATH"/add-event.ts to a higher module that imports AppModule in "PATH"/app.module.ts and AddEventModule. You can also creat a new NgModule that exports and includes AddEvent then import

Variables with the same name, but the local scope variable isn't being used, why?

倾然丶 夕夏残阳落幕 提交于 2019-11-28 14:42:08
Why is the declaration of the variable 'a' not used in the output of the console log of the below code? Doesn't that go against the scope chain? The variable 'a' with the undefined value on line 4 surely should be used on the console output on line 5? var a = 15; function checkScope(a) { var a; console.log(a); // log outputs 15 and not undefined } checkScope(a); I want to understand this behaviour. To confirm, this behaviour has nothing to do with hoisting or even scope (i.e. scope chain)? I don't believe scope is relevant to explain this behaviour because 'a' exists locally (its value is '

C++ “fatal error LNK1120” unresolved static class members

那年仲夏 提交于 2019-11-28 14:19:58
I get the following error message (someone feel free to edit the unnecessary bits): 1>FIXDecoder.obj : error LNK2001: unresolved external symbol "private: static class std::unordered_map,class std::allocator >,class std::basic_string,class std::allocator >,struct std::hash,class std::allocator > >,struct std::equal_to,class std::allocator > >,class std::allocator,class std::allocator > const ,class std::basic_string,class std::allocator > > > > FD::FixValueMappingsDict" (?FixValueMappingsDict@FD@@0V?$unordered_map@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@U?$hash@V?

How to convert a K&R function declaration to an ANSI function declaration automatically?

自作多情 提交于 2019-11-28 14:05:33
// K&R syntax int foo(a, p) int a; char *p; { return 0; } // ANSI syntax int foo(int a, char *p) { return 0; } As you see, in K&R style, the types of variables are declared in new lines instead of in the braces. How to convert a K&R function declaration to an ANSI function declaration automatically? Does anybody know such an easy-to-use tool in Linux? You can use cproto or protoize (part of GCC) to generate function prototypes or convert old style (K&R) functions to ANSI format. Since You wanna convert a multiline string, you chould consider perl you have void old_style( c , a ) char c; int a;

when to pass a parameter and when to use an instance variable

不羁的心 提交于 2019-11-28 13:41:33
问题 How do you guys decide between keeping track of something locally and then just passing it in to every method you call on it, or declaring an instance variable and using it in the methods? I tend to prefer instance variables kept in a list at the end of the Class. But as my programs become more and more complicated, this list gets longer and longer... I figure that if something is getting passed often enough it should just be visible to all the boys and girls who need it, but then I start

Assign values of array to separate variables in one line

六眼飞鱼酱① 提交于 2019-11-28 11:54:44
Can I assign each value in an array to separate variables in one line in C#? Here's an example in Ruby code of what I want: irb(main):001:0> str1, str2 = ["hey", "now"] => ["hey", "now"] irb(main):002:0> str1 => "hey" irb(main):003:0> str2 => "now" I'm not sure if what I'm wanting is possible in C#. Edit: for those suggesting I just assign the strings "hey" and "now" to variables, that's not what I want. Imagine the following: irb(main):004:0> val1, val2 = get_two_values() => ["hey", "now"] irb(main):005:0> val1 => "hey" irb(main):006:0> val2 => "now" Now the fact that the method get_two

Templates and headers question

て烟熏妆下的殇ゞ 提交于 2019-11-28 11:46:18
The compiler says it can't find the reference for the function when I do this: // link.h template <class T> T *Link(T *&, T *(*)()) // link.cpp template <class T> T c:Link(T *&ChildNodeReference, T *(*ObjectCreator)()){ } If I implement inside the class on the header it goes smoothly. Please, I will work on the header until someone enlightens me about this. There are somethings in C++ that are weirdly annoying. I know, there is a reason for this and etc. Even so, can't the compilers help you out about it -_-" Programming non-template code or non-inlined functions in headers is a Bad Thing™.

Can a variable be defined only in the scope of an if-statement, similar to how it's often done for for-loops?

对着背影说爱祢 提交于 2019-11-28 08:56:55
问题 Is there a way to declare, assign and compare a variable to an expression in an if construction in such a way that it is only defined in the scope of the if construction? This works (declare and assign, but of course the condition is only the return value of function f being equal to zero or not): int main() { if(int i = f()) { printf("%d", i); // i is defined here! } else { // Here too! } // But not here! } But when I try to compare the value of i with an actual expression I run into trouble

Benefits of declaring a function as “inline”?

*爱你&永不变心* 提交于 2019-11-28 08:46:34
Every time I read about the "inline" declaration in C it is mentioned that it is only a hint to the compiler (i.e. it does not have to obey it). Is there any benefit to adding it then, or should I just rely on the compiler knowing better than me? There are two reasons to use the inline keyword. One is an optimization hint, and you can safely ignore it; your compiler is like to ignore it too. The other reason is to allow a function to exist in multiple translation units, and that usage is strictly necessary. If you put a function into a .h header file for example, you'd better declare it inline