接続数

COUNTER379658FROM 2012/5/16

MISRA-C diary(C言語日誌)

MISRA-C >> Article details

2014/06/10

C++N3242,2011(3a) 1 General 1.9 Program execution

Tweet ThisSend to Facebook | by kaizen
// 1 filename:cpp2011-1-19.cpp
//ver 0.1 June.10, 2014
// 2 original examples and/or notes:
// (c) ISO/IEC JTC1 SC22 WG21 N3242, April 12, 2011
//
// 3 compile and output mechanism:
// (c) Ogawa Kiyoshi, kaizen@gifu-u.ac.jp,
//
// 4 compile errors and/or wornings:
// 4.1(c) Apple LLVM version 4.2 (clang-425.0.27) (based on LLVM 3.2svn)
// Target: x86_64-apple-darwin11.4.2 //Thread model: posix
//Xcode 5.0.2/LLVM version 4.2 (clang-425.0.27) (based on LLVM 3.2svn)
//Command/Options: cc -std=c11 -Wall misra-C-2-1-ex-ui-wicm4a.c 
// (c) LLVM 2003-2009 University of Illinois at Urbana-Champaign.
// 4.2. gcc-4.9 (GCC) 4.9.0 20131229 (experimental) C90/C99/C2011, 32/64 bit, http://gcc.gnu.org/onlinedocs/gcc/Standards.html
//      Copyright (C) 2013 Free Software Foundation, Inc. http://gcc.gnu.org/gcc-4.9/changes.html
//Command/Options: gcc std=c11 -Wall misra-C-2-1-ex-ui-wicm4a.c 
//Configuration:brew install gcc49
//
// 4.3. Visual Studio Express 2013, 
//(c) Microsoft http://www.visualstudio.com/
//SPEC:'most of C99/C11 that is a subset of ISO C++98/C++11'.
//http://visualstudio.uservoice.com/forums/121579-visual-studio/suggestions/2089423-c99-support
//Windows 7, .NET Framework
//(c) VMware, Inc.
//VMWare fusion 6
//
// 4.4 M3T-NC30WA V.5.45 Release 01
//(c) Renesas Electronics Corporation.http://www.renesas.com/products/mpumcu/m16c/
//using M16C M8C simulator, M8C36
//SPEC:C90, 16 bit
//
// 5. Hardware:  MacBook Pro, 
//(c) Intel http://ark.intel.com/products/37006/
//Core 2 Duo 2.53GHz, 8GB, 1067MHz DDR3
//
// 6. Special Thanks: Upper organizatios and 
//ISO/IEC JTC1 SC22 WG14, http://www.open-std.org/jtc1/sc22/wg14/www/standards
//ITSCJ/IPSJ http://www.itscj.ipsj.or.jp/itscj_english/index.html
//Daido Universcity, http://www.daido-it.ac.jp/gakubugakka/computer/index.html
//IT planning Inc., http://www.itpl.co.jp/en/index.html
//Spancion Inc., http://www.spansion.com/
//SWEST: Summer Workshop on Embedded System Technologies , http://swest.toppers.jp
//CEST: Consortium for Embedded System Technology, http://www.ertl.jp/CEST/
//OSC:Open Source Conference, http://www.ospn.jp/

// 1 filename:c2011-3-14-ex.
//ver 0.1 December.29, 2013
//ver0.2 January 11, 2014 add 2 sets of input for clarify about warning and assignment.
//
// 2 original examples and/or notes:
// (c) ISO/IEC JTC1 SC22 WG14 N1570, April 12, 2011
// http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf
// C2011 3.14 memory location
//
// 3 compile and output mechanism:
// (c) Ogawa Kiyoshi, kaizen@gifu-u.ac.jp, December.29, 2013
//
// 4 compile errors and/or wornings:
// 4.1(c) Apple LLVM version 4.2 (clang-425.0.27) (based on LLVM 3.2svn)
// Target: x86_64-apple-darwin11.4.2 //Thread model: posix
//Xcode 5.0.2/LLVM version 4.2 (clang-425.0.27) (based on LLVM 3.2svn)
//Command/Options: cc -std=c11 -Wall misra-C-2-1-ex-ui-wicm4a.c 
// (c) LLVM 2003-2009 University of Illinois at Urbana-Champaign.
// 4.2. gcc-4.9 (GCC) 4.9.0 20131229 (experimental) C90/C99/C2011, 32/64 bit, http://gcc.gnu.org/onlinedocs/gcc/Standards.html
//      Copyright (C) 2013 Free Software Foundation, Inc. http://gcc.gnu.org/gcc-4.9/changes.html
//Command/Options: gcc std=c11 -Wall misra-C-2-1-ex-ui-wicm4a.c 
//Configuration:brew install gcc49
//
// 4.3. Visual Studio Express 2013, 
//(c) Microsoft http://www.visualstudio.com/
//SPEC:'most of C99/C11 that is a subset of ISO C++98/C++11'.
//http://visualstudio.uservoice.com/forums/121579-visual-studio/suggestions/2089423-c99-support
//Windows 7, .NET Framework
//(c) VMware, Inc.
//VMWare fusion 6
//
// 4.4 M3T-NC30WA V.5.45 Release 01
//(c) Renesas Electronics Corporation.http://www.renesas.com/products/mpumcu/m16c/
//using M16C M8C simulator, M8C36
//SPEC:C90, 16 bit
//
// 5. Hardware:  MacBook Pro, 
//(c) Intel http://ark.intel.com/products/37006/
//Core 2 Duo 2.53GHz, 8GB, 1067MHz DDR3
//
// 6. Special Thanks: Upper organizatios and 
//ISO/IEC JTC1 SC22 WG14, http://www.open-std.org/jtc1/sc22/wg14/www/standards
//ITSCJ/IPSJ http://www.itscj.ipsj.or.jp/itscj_english/index.html
//Daido Universcity, http://www.daido-it.ac.jp/gakubugakka/computer/index.html
//IT planning Inc., http://www.itpl.co.jp/en/index.html
//Spancion Inc., http://www.spansion.com/
//SWEST: Summer Workshop on Embedded System Technologies , http://swest.toppers.jp
//CEST: Consortium for Embedded System Technology, http://www.ertl.jp/CEST/
//OSC:Open Source Conference, http://www.ospn.jp/

#include <iostream>
using namespace std;

int main()
{
int a, b;
/* ... */
a=1;
b=1;
a = a + 32760 + b + 5;
cout << a;
a = (((a + 32760) + b) + 5);
cout << a;

a = ((a + b) + 32765);

cout <<a;


a = ((a + 32765) + b);
cout << a;
a = (a + (b + 32765));
cout << a;
return a;
}

//Undefined symbols for architecture x86_64:
//  "std::ostream::operator<<(int)", referenced from:
//      _main in cpp_1_9-B9hyMl.o
//  "std::ios_base::Init::Init()", referenced from:
//      ___cxx_global_var_init in cpp_1_9-B9hyMl.o
//  "std::ios_base::Init::~Init()", referenced from:
//      ___cxx_global_var_init in cpp_1_9-B9hyMl.o
//  "std::cout", referenced from:
//      _main in cpp_1_9-B9hyMl.o
//ld: symbol(s) not found for architecture x86_64
//clang: error: linker command failed with exit code 1 (use -v to see invocation)

20180423追記

## Compiler
###clang++ --version
clang version 6.0.0 (tags/RELEASE_600/final)

###g++-7 --version
g++-7 (Homebrew GCC 7.3.0_1) 7.3.0
Copyright (C) 2017 Free Software Foundation, Inc.

$ ../cppgl17.sh cpp2011-1-19

$ clang++ cpp2011-1-19.cpp -std=c++17 

327676553398299131065163831

$ g++-7 cpp2011-1-19.cpp -std=c++17 

327676553398299131065163831

---
cppgl17.sh

#!/bin/sh

echo "$ clang++ $1.cpp -std=c++17 "

clang++ $1.cpp -std=c++17 -o $1l

if [  -e $1l ]; then

./$1l $2

fi

echo "\r"

echo "$ g++-7 $1.cpp -std=c++17 "

g++-7 $1.cpp  -std=c++17 -o $1g

if [  -e $1g ]; then

./$1g $2

fi



<この稿は書きかけです。順次追記しています。>
twitter:@kaizen_nagoya
17:24 | Impressed! | Voted(0) | Comment(0)