Why VC++ instead of Dev C++?

Similar documents
Short Notes of CS201

Pointers, Dynamic Data, and Reference Types

Programming. C++ Basics

CS201 - Introduction to Programming Glossary By

WARM UP LESSONS BARE BASICS

A Fast Review of C Essentials Part I

Programming in C++ Prof. Partha Pratim Das Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur

C-LANGUAGE CURRICULAM

1- Write a single C++ statement that: A. Calculates the sum of the two integrates 11 and 12 and outputs the sum to the consol.

CS3157: Advanced Programming. Outline

Input And Output of C++

Introduction to C++ Systems Programming

Arrays. Example: Run the below program, it will crash in Windows (TurboC Compiler)

6.096 Introduction to C++ January (IAP) 2009

Features of C. Portable Procedural / Modular Structured Language Statically typed Middle level language

AN OVERVIEW OF C++ 1

CS2141 Software Development using C/C++ C++ Basics

Introduction to Programming Using Java (98-388)

OBJECT ORIENTED PROGRAMMING

CSCI 171 Chapter Outlines

AMCAT Automata Coding Sample Questions And Answers

PROGRAMMING IN C++ KAUSIK DATTA 18-Oct-2017

Outline. 1 Function calls and parameter passing. 2 Pointers, arrays, and references. 5 Declarations, scope, and lifetimes 6 I/O

Computers Programming Course 5. Iulian Năstac

Technical Questions. Q 1) What are the key features in C programming language?

Chapter 6: User-Defined Functions. Objectives (cont d.) Objectives. Introduction. Predefined Functions 12/2/2016

1. In C++, reserved words are the same as predefined identifiers. a. True

Absolute C++ Walter Savitch


Fast Introduction to Object Oriented Programming and C++

Chapter 15 - C++ As A "Better C"

UEE1302 (1102) F10: Introduction to Computers and Programming

PERIYAR CENTENARY POLYTECHNIC COLLEGE Periyar Nagar- Vallam Thanjavur

Unit 7. Functions. Need of User Defined Functions

1. Describe History of C++? 2. What is Dev. C++? 3. Why Use Dev. C++ instead of C++ DOS IDE?

Recap. ANSI C Reserved Words C++ Multimedia Programming Lecture 2. Erwin M. Bakker Joachim Rijsdam

CS201 Some Important Definitions

Introduction to C++ Introduction. Structure of a C++ Program. Structure of a C++ Program. C++ widely-used general-purpose programming language

CS

Pointers and Arrays CS 201. This slide set covers pointers and arrays in C++. You should read Chapter 8 from your Deitel & Deitel book.

H.O.#2 Fall 2015 Gary Chan. Overview of C++ Programming

CS 376b Computer Vision

Introduction to C++ with content from

Final CSE 131B Spring 2004

CS Programming In C

BLM2031 Structured Programming. Zeyneb KURT

CSC 211 Intermediate Programming. Arrays & Pointers

2.1. Chapter 2: Parts of a C++ Program. Parts of a C++ Program. Introduction to C++ Parts of a C++ Program

Overview. - General Data Types - Categories of Words. - Define Before Use. - The Three S s. - End of Statement - My First Program

Chapter 2: Introduction to C++

Preface... (vii) CHAPTER 1 INTRODUCTION TO COMPUTERS

C++ for Java Programmers

Chapter 2: Special Characters. Parts of a C++ Program. Introduction to C++ Displays output on the computer screen

CSE 124 Discussion (10/3) C/C++ Basics

IECD Institute for Entrepreneurship and Career Development Bharathidasan University, Tiruchirappalli 23.

Topic 6: A Quick Intro To C. Reading. "goto Considered Harmful" History

QUIZ. What is wrong with this code that uses default arguments?

Basic memory model Using functions Writing functions. Basics Prototypes Parameters Return types Functions and memory Names and namespaces

CSCE Practice Midterm. Data Types

QUIZ. 1. Explain the meaning of the angle brackets in the declaration of v below:

Structured Programming Using C++ Lecture 2 : Introduction to the C++ Language. Dr. Amal Khalifa. Lecture Contents:

Program Organization and Comments

Introduction to Programming using C++

Introduction to C++ Professor Hugh C. Lauer CS-2303, System Programming Concepts

Welcome Back. CSCI 262 Data Structures. Hello, Let s Review. Hello, Let s Review. How to Review 8/19/ Review. Here s a simple C++ program:

SRM ARTS AND SCIENCE COLLEGE SRM NAGAR, KATTANKULATHUR

Outline. Introduction. Arrays declarations and initialization. Const variables. Character arrays. Static arrays. Examples.

Contents. C++ As a Better C. Comments. User-defined Type Names

CSCE 110 PROGRAMMING FUNDAMENTALS

CSE 374 Programming Concepts & Tools. Hal Perkins Fall 2015 Lecture 19 Introduction to C++

C++ As a Better C. C++ Object Oriented Programming Pei-yih Ting NTOU CS

Your First C++ Program. September 1, 2010

Evolution of Programming Languages

Chapter 2 Basic Elements of C++

Type Checking. Prof. James L. Frankel Harvard University

CS 261 Fall C Introduction. Variables, Memory Model, Pointers, and Debugging. Mike Lam, Professor

Topic 6: A Quick Intro To C

7.1 Optional Parameters

The component base of C language. Nguyễn Dũng Faculty of IT Hue College of Science

Global & Local Identifiers

C Programming. Course Outline. C Programming. Code: MBD101. Duration: 10 Hours. Prerequisites:

Interview Questions of C++

Pointers II. Class 31

Quiz1 Fall 2007 October 2 nd, UNIVERSITY OF WINDSOR Fall 2007 QUIZ # 1 Solution. Examiner:Ritu Chaturvedi Dated :October 2nd, 2007.

Programming and Data Structure

IMPORTANT QUESTIONS IN C FOR THE INTERVIEW

ANSI C. Data Analysis in Geophysics Demián D. Gómez November 2013

Complex data types Structures Defined types Structures and functions Structures and pointers (Very) brief introduction to the STL

GE U111 Engineering Problem Solving & Computation Lecture 6 February 2, 2004

MM1_ doc Page E-1 of 12 Rüdiger Siol :21

Dynamic Memory Allocation and Command-line Arguments

Objectives. In this chapter, you will:

Introduction to the C Programming Language

Lecture 2: C Programming Basic

FORM 1 (Please put your name and section number (001/10am or 002/2pm) on the scantron!!!!) CS 161 Exam II: True (A)/False(B) (2 pts each):

Full file at C How to Program, 6/e Multiple Choice Test Bank

cs3157: c++ lecture #2 (mon-11-apr-2005) chronology of some programming languages... C++ vs Java identifiers.

Programming, numerics and optimization

Kingdom of Saudi Arabia Princes Nora bint Abdul Rahman University College of Computer Since and Information System CS242 ARRAYS

C, C++, Fortran: Basics

Transcription:

Why VC++ instead of Dev C++?

I love UNIX! I am proficient in UNIX! I like public domain open source software. I love GPL. I was more confident in GCC than in Microsoft C. But! The software business has changed so much since year 1990. One man heroic software is no more astonishing and reliable. Instead, software engineers together contribute to the functionalities of a package. 2

Dev-C++ 5.0 beta 9.2 (4.9.9.2) 2005-02-21 is a Win32 porting (Mingw) of GNU GCC 3.4.2 http://www.bloodshed.net/devcpp.html http://www.bloodshed.net/dev/devcpp.html 3

#include <stdio.h> int main (void) { char *filename; Problem #1 } printf ("Please input the filename of the data. (ex: " " pixelsimage1.dat)\n\n >> "); scanf ("%s", filename); return 0; This does not cause any runtime error!! Is it only too lucky for this or OK to use every unallocated memory? 4

Problem #2 int fun(int size) { int a[size]; } int s = -10; fun(s); https://gcc.gnu.org/onlinedocs/gcc/variable-length.html Variable Length Array (VLA) of ISO C99 Since a is allocated on the system stack, this can be implemented. However, at least some dynamic check of array size is necessary. malloc() has return value but VLA does not. Could you imagine that this is not a compile time error and even not a runtime error in some context? I verified that GCC 3.4 accepts this but VC series do not. Poor portability, not supported in ANSI C++ 5

Problem #3 #include <iostream> using namespace std; int main() { char hexnum[8]; char temp[8]; cin >> hexnum; temp = hexnum; cout << temp; return 0; } VC error C2106: '=' : left operand must be l-value g++ 4.8.3 error: invalid array assignment But no error in g++ 3.4.2 Can you imagine that this is allowed in Dev C++ 4.9.9.2? 6

Problem #4 Tolerate missing return statements #include <stdio.h> 2015/12/28 int square(int x) { devcpp 5.11 MingW(gcc 4.8.1, g++ 4.8.1) int z = x * x; int y; y = 10*x+1; } int main() { printf("%d\n", square(10)); } This is really a nightmare to debug a 300-line program from a novice programmer. This is still a major problem for a real software package by an experienced programmer. 7

file name with spaces Problem #5 8

9

Disaster!! 10

In a project xxx.dev Problem #6 yyy.c is compiled by g++ if you select C++ project as you create your project 11

Summary I am not demonstrating that Dev C++ is of no use. In fact, these problems do not affect my work at all. I seldom commit the first or the third error, at least not when I am sober. I never use the second extended grammar of g++. Thus, what I am saying is that Dev C++ is OK for welltrained programmers but clearly not for novice programmers. C treats you like a consenting adult especially the public domain Dev-C++ and GNU C/C++ Not detecting these problems should be a very serious crime and help cultivating bad habits for a beginning programmer or just destroying his likely shining career. Saving money should not be blamed and given in return an inferior compiler. 12

Other GCC Extensions http://tigcc.ticalc.org/doc/gnuexts.html Some features that are in ISO C99 but not C89 are also, as extensions, accepted by GCC in C89 mode. Statements and Declarations in Expressions Locally Declared Labels Structures With No Members Arrays of Length Zero Labels as Values Arrays of Variable Length Nested Functions Macros with a Variable Constructing Function Calls Number of Arguments Referring to a Type with 'typeof' Non-Lvalue Arrays May Have Generalized Lvalues Subscripts Conditionals with Omitted Arithmetic on void and Operands Function Pointers Non-Constant Initializers Double-Word Integers Compound Literals (Cast Complex Numbers Constructors) Hex Floats Designated Initializers 13

Cast to a Union Type Alternate Keywords Case Ranges Incomplete 'enum' Types Specifying Attributes of Function Names as Strings Functions Getting the Return or Frame Specifying Attributes of Address of a Function Variables Other built-in functions provided Specifying Attributes of Types by GCC Attribute Syntax Slightly Looser Rules for Escaped Prototypes and Old-Style Newlines Function Definitions String Literals with Embedded C++ Style Comments Newlines Dollar Signs in Identifier Mixed Declarations and Code Names Unnamed struct/union Fields Escape Character in Constants within structs/unions Inquiring on Alignment of Definite Access of Volatile Types or Variables Objects Inline Functions History Inline Assembler GNU General Public License Controlling Names Used in GNU Free Documentation License Assembler Code Funding Free Software Variables in Specified Registers 14

15

Not really a Problem #include <iostream> #include <string> #include <math.h> using namespace std; int main() { char id[2]; id[0]='5'; cout << id[0] << endl; cout << (int)id[0] << endl; cout << (int)pow(id[0],2) << endl; cout << (int)pow(id[0],3) << endl; cout << (int)pow(id[0],4) << endl; return 0; } Dev C++ 5 53 2809 148876 7890481 VC6 5 53 2809 148877 7890481 16