Questions tagged [ansi-c]

ANSI C is an informal term sometimes used when referring to the C programming language standard published by the American National Standards Institute (ANSI) in 1989 .

"ANSI C" is an informal term used to refer to the 1989 version of the C language. The formal name for this version of the language is ISO/IEC 9899:1990. Informally it is also known as "C89" or "C90".

This is because the American National Standards Institute (ANSI) first published this standard in the year 1989, as a national standard for the USA. It became international ISO standard in the year 1990. So ANSI C, C89 and C90 all refer to the same technical standard.

It is a common misunderstanding that "ANSI C" means standard compliant C. The ANSI standard institute haven't had anything to do with C since 1989. The language is maintained by ISO SC22/WG14. Yet the term "ANSI C" is sometimes used to mean standard compliant, particularly in old books and by old compilers.

Because of this ambivalent meaning, please avoid using this tag. For questions regarding the C89/C90 version of the C language, please use . For questions regarding standard-compliant C, simply use the tag.

Further information about the different C standard versions.

618 questions
6
votes
2 answers

VS2010 C and C++ - enforce ANSI compliance for Linux/gcc compatibility?

I'm taking a class in which I'm required to write some C++ apps for Linux. I really, really dislike the dev tools available under Linux, but I love VS2010. Is there any sort of compiler switch which will enforce ANSI or gcc compatibility in VC++? Or…
3Dave
  • 28,657
  • 18
  • 88
  • 151
6
votes
2 answers

Declare variable in if statement (ANSI C)

Is there any way to declare variable in if statement (using ANSI C only) ? Example: if(int variable = some_function()) { return 1; }
ARTAGE
  • 379
  • 2
  • 4
  • 14
6
votes
2 answers

-Wsequence-point warning - what does it mean and does it violate ANSI C standard?

In line tab[i] = tab[i+1] - tab[i] + (tab[i+1] = tab[i]); I have a warning [Warning] operation on '*(tab + ((sizetype)i + 1u) * 4u)' may be undefined [-Wsequence-point] I want to swap these two integer arrays elements without temporary variable…
residue
  • 207
  • 5
  • 18
6
votes
1 answer

Rationale for pre-C99 C not having initial declarations in for loops?

Why did the original C language not support initial declarations in for loop initializations? Obviously the original creators, and then the pre-C99 standardizations, didn't specify it that way. But I can't seem to find any rationale for why that…
mtraceur
  • 3,254
  • 24
  • 33
6
votes
1 answer

'revealing' hidden/control 'codes' in strings in bash

There a very handy function in Python: repr() which when applied on a string containing blank characters will print out a representation of that string that cannot lead to any human misinterpretation of the string actual content. for instance: $…
Thomasleveil
  • 95,867
  • 15
  • 119
  • 113
6
votes
4 answers

Nested typedef structs

I'm having an issue trying to nest structs that I need to declare as new var types. The code is the following- typedef struct { typedef struct { int day, month, year; } Date; Date manuDate, …
James McGrath
  • 187
  • 1
  • 4
  • 15
6
votes
2 answers

Sorting 2-dimensional array in ANSI C with qsort()

I have a two dimensional array and want to sort both rows depending on the order of the elements in the first row: i start with: row1: { 4, 3, 1, 5, 0} row2: { 7, 8, 9, 1, 2} and the result should be: row1: { 0, 1, 3, 4, 5} row2: { 2, 9, 8, 7,…
andreas
  • 117
  • 1
  • 7
6
votes
3 answers

Why do -ansi and -std=c++11 conflict in g++?

Why does -ansi and -std=c++11 doesn't work together ? (ANSI reverts back to C++98 according to other answers) I am using g++-4.8. Here is the ANSI ratification of C++11…
Jean-Michaël Celerier
  • 7,412
  • 3
  • 54
  • 75
6
votes
2 answers

IAR Embedded workbench create library

I want to create a simple library (C/ANSI) in IAR Embedded Workbench and then use the library in another project. I found some documentation on their website. Although I do not understand it entirely, I managed to make myself a .r90 file and from…
Teo
  • 3,394
  • 11
  • 43
  • 73
6
votes
2 answers

What kind of non-lethal code usually triggers an antivirus? (false positives)

I don't know why, but I've had no problem before and now all of a sudden, this really old, terrible, newbie program that I wrote a long time ago, triggers Malwarebytes... :( This question is not a duplicate, since the program in question is in…
Joe DF
  • 5,438
  • 6
  • 41
  • 63
6
votes
3 answers

Does "ANSI C" or "ANSI C++" still mean something today?

Last time I checked, saying that you are coding in ANSI C was equal to say "this is C99 compliant code with nothing else in it". Now with C11 and C++11, does this distinction still remain? Does it still has some sort of meaning?
user1849534
  • 2,329
  • 4
  • 18
  • 20
6
votes
3 answers

Initialize struct members to 0 (gcc -Wextra)

I want to initialize all struct members to 0. Common solution is to make something like this: struct foo bar = {0} I create this example: #include struct Stru2 { int c; int d; }; struct Stru1 { int a; Stru2 b; }; int…
NiegodziwyBeru
  • 864
  • 1
  • 10
  • 19
6
votes
1 answer

Where would I go with an idea for the next C standard?

I've been reading up a lot on how C works, and I think I have an idea for how to make it better. From what I've read it seems like the standard changes from time to time, and I was wondering if there is a place I could go to submit a new idea for…
Noah
  • 351
  • 2
  • 9
5
votes
6 answers

Errors compiling example from ANSI C book, Linked Lists chapter

I am doing some examples out of an older C book [A First Book of ANSI C] and am getting an error while trying to compile this example code: #include struct tele_typ { char name[30]; char phone_no[15]; struct tele_typ…
nak
  • 3,077
  • 3
  • 27
  • 35
5
votes
1 answer

calling virtual functions through pointers with and without consulting the VM-table

I want to take the address of a member function of a c++ class, store it in a pointer, and call the virtual function later on. I know some things about it, but do not now how to take the address of a certain implementation of a virtual function…
bert-jan
  • 958
  • 4
  • 15