c99

What is the default C mode for the current gcc (especially on Ubuntu)?

断了今生、忘了曾经 提交于 2019-12-17 05:46:05
问题 When I ask to see the current version of cc I get this. $ cc --version cc (Ubuntu/Linaro 4.7.2-2ubuntu1) 4.7.2 Copyright (C) 2012 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. $ What I would like to know is which of c89, c90, c99 or c11 is being used. 回答1: This is explained in depth in the gcc manual, available (if it's installed) by typing info gcc or online

state machines tutorials [closed]

断了今生、忘了曾经 提交于 2019-12-17 03:44:52
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 3 years ago . I am just wondering if anyone know of some good tutorials on the Internet for developing state machines. Or ebooks? I am starting working on state machines and just need something general to get me started. 回答1: State machines are very simple in C if you use function pointers. Basically you need 2 arrays - one

What is the correct type for array indexes in C?

断了今生、忘了曾经 提交于 2019-12-17 03:36:21
问题 What type for array index in C99 should be used? It have to work on LP32, ILP32, ILP64, LP64, LLP64 and more. It doesn't have to be a C89 type. I have found 5 candidates: size_t ptrdiff_t intptr_t / uintptr_t int_fast*_t / uint_fast*_t int_least*_t / uint_least*_t There is simple code to better illustrate problem. What is the best type for i and j in these two particular loops. If there is a good reason, two different types are fine too. for (i=0; i<imax; i++) { do_something(a[i]); } /* jmin

C99 boolean data type?

前提是你 提交于 2019-12-17 02:47:05
问题 What's the C99 boolean data type and how to use it? 回答1: Include <stdbool.h> header #include <stdbool.h> int main(void){ bool b = false; } Macros true and false expand to 1 and 0 respectively. Section 7.16 Boolean type and values < stdbool.h > 1 The header <stdbool.h> defines four macros. 2 The macro bool expands to _Bool. 3 The remaining three macros are suitable for use in #if preprocessing directives. They are true : which expands to the integer constant 1, false: which expands to the

C99 inline function in .c file

邮差的信 提交于 2019-12-17 02:36:37
问题 I defined my function in .c (without header declaration) as here: inline int func(int i) { return i+1; } Then in the same file below I use it: ... i = func(i); And during the linking I got "undefined reference to 'func'". Why? 回答1: The inline model in C99 is a bit different than most people think, and in particular different from the one used by C++ inline is only a hint such that the compiler doesn't complain about doubly defined symbols. It doesn't guarantee that a function is inlined, nor

C99 stdint.h header and MS Visual Studio

a 夏天 提交于 2019-12-16 20:15:48
问题 To my amazement I just discovered that the C99 stdint.h is missing from MS Visual Studio 2003 upwards. I'm sure they have their reasons, but does anyone know where I can download a copy? Without this header I have no definitions for useful types such as uint32_t, etc. 回答1: Turns out you can download a MS version of this header from: https://github.com/mattn/gntp-send/blob/master/include/msinttypes/stdint.h A portable one can be found here: http://www.azillionmonkeys.com/qed/pstdint.h Thanks

Are there reasons to avoid bit-field structure members?

可紊 提交于 2019-12-14 03:44:48
问题 I long knew there are bit-fields in C and occasionally I use them for defining densely packed structs: typedef struct Message_s { unsigned int flag : 1; unsigned int channel : 4; unsigned int signal : 11; } Message; When I read open source code, I instead often find bit-masks and bit-shifting operations to store and retrieve such information in hand-rolled bit-fields. This is so common that I do not think the authors were not aware of the bit-field syntax, so I wonder if there are reasons to

When to use the plain char type in C

♀尐吖头ヾ 提交于 2019-12-14 02:22:59
问题 In plain C, by the standard there are three distinct "character" types: plain char which one's signedness is implementation defined. signed char . unsigned char . Let's assume at least C99, where stdint.h is already present (so you have the int8_t and uint8_t types as recommendable alternatives with explicit width to signed and unsigned chars). For now for me it seems like using the plain char type is only really useful (or necessary) if you need to interface functions of the standard library

_Bool data type of C99

橙三吉。 提交于 2019-12-14 00:33:27
问题 The C99 standard of the C programming language defines the _Bool data type as a macro for another data type (as the language isn't able to deal with a type safe boolean). Is the _Bool a macro for unsigned char , unsigned int or some other data type? 回答1: _Bool is a separate integere type that according to the C Standard. _Bool is a keyword of the C language. 2 An object declared as type _Bool is large enough to store the values 0 and 1. _Bool is unsigned integer type. The type _Bool and the

C99 - vscanf for dummies? [closed]

拥有回忆 提交于 2019-12-13 20:34:11
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 6 years ago . I am sorry to bother S.O. with such a general request for information. I can find plenty of very terminology-heavy definitions of vscanf - but I can't find much in the way of concrete examples which will show