接続数

COUNTER239262FROM 2012/5/16

MISRA-C diary(C言語日誌)

12345
2017/09/21new

C言語仕様でC++ 言語仕様で動かないもの

Tweet ThisSend to Facebook | by kaizen
C++ 言語仕様の中に残っているC言語仕様



プログラミング言語人気TOP10の簡易解説
Effective C++ 第3版 (ADDISON-WESLEY PROFESSIONAL COMPUTI)
スコット メイヤーズ
丸善出版(2014/03/18)


を推奨している。


主要なプログラミング言語8種をざっくり解説 - shi3zの長文日記
C言語は1999年から//があるのに//はC++とか書いてる。
11:40 | 投票する | 投票数(0) | コメント(0)
2017/09/18new

DCL53-CPP. Do not write syntactically ambiguous declarations

Tweet ThisSend to Facebook | by kaizen
// 1 filename: DCL53.cpp
// ver 0.1 18(Mon), Aug, 2017

#include <iostream>
#include <string>
#include <cstdarg>

// 2 original examples and/or notes:
// (c) SEI CERT, C++ Coding standard
// https://www.securecoding.cert.org/confluence/pages/viewpage.action?pageId=637
std::string ru ( "Rule 01. Declarations and Initialization (DCL) ");
std::string rus ( " DCL53-CPP. Do not write syntactically ambiguous declarations");
//  David Svoboda Create, 8 01, 2017  G. Ann Campbell Last update
//
// 3 compile and output mechanism:
// (c) Dr. OGAWA Kiyoshi, kaizen at wh.commufa.jp,
//
// 4 compile errors and/or warnings:
// 4.1  Clang  http://www.llvm.org/
// Copyright (c) 2003-2017, LLVM Project
// clang++ --version
// (c) clang version 5.0.0 (tags/RELEASE_500/final)
// Target: x86_64-apple-darwin14.5.0
// Thread model: posix
// InstalledDir: /usr/local/opt/llvm/bin
// Base standard: https://clang.llvm.org/cxx_status.html
// Command/Options: clang++ -std=c++14 -stdlib=libc++ -Wall DCL53.cpp -o DCL53L
// Configuration: brew install --with-clang llvm
//
// 4.2. g++ (Homebrew GCC 6.4.0) 6.4.0
// Copyright (C) 2017 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.
// ln -s /usr/local/bin/gcc-6 /usr/local/bin/gcc
// ln -s /usr/local/bin/g++-6 /usr/local/bin/g++
// Base standard: http://gcc.gnu.org/onlinedocs/gcc/Standards.html
// Command/Options: g++  -std=c++14  -Wall DCL53.cpp  -o DCL53G
// Configuration:brew install gcc6
//
// 5. Hardware:  MacBook Pro,  (Retina, 13-inch, Mid 2014)
// OS X 10.10.5 Yosemite
//Core i5, 2.6GHz, 16GB, 1600MHz DDR3
//(c) Intel http://ark.intel.com/products/series/75024/4th-Generation-Intel-Core-i5-Processors
//
// 6. Special Thanks: Upper organizatios and
// ISO/IEC JTC1 SC22 WG21: http://www.open-std.org/jtc1/sc22/wg21/
// MISRA: https://www.misra.org.uk/forum/index.php
// ISO/IEC JTC1 SC22 WG14: http://www.open-std.org/jtc1/sc22/wg14/
// ITSCJ/IPSJ http://www.itscj.ipsj.or.jp/itscj_english/index.html
// Renesas Electronics Corporation.http://www.renesas.com/
// NPO SESSAME project, http://www.sessame.jp/workinggroup/WorkingGroup3/
// Toyo Corporation, http://www.toyo.co.jp/English/
// Japan Standard Association, http://bit.ly/1lzykg1
// NPO TOPPERS project, https://www.toppers.jp/asp-d-download.html
// Daido Universcity, http://www.daido-it.ac.jp/gakubugakka/computer/index.html
// WITZ Co.Ltd., http://www.witz-inc.co.jp/products/solution/solution.html
// SevenWise.Co., http://www.7ws.co.jp/index.html
// TOYOTA Motor Corporation, http://toyota.jp/
// DENSO Corporation, http://www.globaldenso.com/en/
// Aisin Seiki Co. Ltd., http://www.aisin.com/
// Cypress Semiconductor Corp., http://japan.cypress.com/
// Yazaki Corporation, http://www.yazaki-group.com/global/
// Pananosic Corporation, http://www.panasonic.net/
// Denso Create Inc.: http://www.denso-create.jp
// SWEST: Summer Workshop on Embedded System Technologies , http://swest.toppers.jp
// CEST: Consortium for Embedded System Technology, http://www.ertl.jp/CEST/
// JUSE: Union of Japanese Scientists and Engineers, http://www.juse.or.jp/e/
// OSC: Open Source Conference, http://www.ospn.jp/

// 7. notes
//{C} Cert C++ text
//{L} LLVM warnings and errors
//{G} Gcc warning and errors
//{S} C++ standard, ISO/IEC JTC1 SC22 WG14
// add 'n' to function and variable names of non compliant example if a same name exists. And sequence number also.
// add 'c' to  function and variable names of compliant examples if a same name exists. And sequence number also.
// adding some output command by Dr O.K.

// 8. program and text
//{C} It is possible to devise syntax that can ambiguously be interpreted as either an expression statement or a declaration. Syntax of this sort is called a vexing parse because the compiler must use disambiguation rules to determine the semantic results. The C++ Standard, [stmt.ambig], paragraph 1 [ISO/IEC 14882-2014], in part, states the following:
//{S}     There is an ambiguity in the grammar involving expression-statements and declarations: An expression-statement with a function-style explicit type conversion as its leftmost subexpression can be indistinguishable from a declaration where the first declarator starts with a (. In those cases the statement is a declaration. [Note: To disambiguate, the whole statement might have to be examined to determine if it is an expression-statement or a declaration. ...
//{C} A similarly vexing parse exists within the context of a declaration where syntax can be ambiguously interpreted as either a function declaration or a declaration with a function-style cast as the initializer. The C++ Standard, [dcl.ambig.res], paragraph 1, in part, states the following:
//{S}    The ambiguity arising from the similarity between a function-style cast and a declaration mentioned in 6.8 can also occur in the context of a declaration. In that context, the choice is between a function declaration with a redundant set of parentheses around a parameter name and an object declaration with a function-style cast as the initializer. Just as for the ambiguities mentioned in 6.8, the resolution is to consider any construct that could possibly be a declaration a declaration.
//{C}Do not write a syntactically ambiguous declaration. With the advent of uniform initialization syntax using a braced-init-list, there is now syntax that unambiguously specifies a declaration instead of an expression statement. Declarations can also be disambiguated by using nonfunction-style casts, by initializing using =, or by removing extraneous parenthesis around the parameter name.
// Noncompliant Code Example
// In this noncompliant code example, an anonymous local variable of type std::unique_lock is expected to lock and unlock the mutex m by virtue of RAII. However, the declaration is syntactically ambiguous as it can be interpreted as declaring an anonymous object and calling its single-argument converting constructor or interpreted as declaring an object named m and default constructing it. The syntax used in this example defines the latter instead of the former, and so the mutex object is never locked.
#include <mutex>
 
static std::mutex m;
static int shared_resource;
 
void increment_by_42n() {
  std::unique_lock<std::mutex>(m);
  shared_resource += 42;
  std::cout << shared_resource << std::endl; // add for output.by Dr O.K.
}
//{C} Compliant Solution
// In this compliant solution, the lock object is given an identifier (other than m) and the proper converting constructor is called.
// #include <mutex>
// static std::mutex m;
// static int shared_resource;
 
void increment_by_42c() {
  std::unique_lock<std::mutex> lock(m);
  shared_resource += 42;
  std::cout << shared_resource << std::endl; // add for output.by Dr O.K.
}
//{C} Noncompliant Code Example
// In this noncompliant code example, an attempt is made to declare a local variable, w, of type Widget while executing the default constructor. However, this declaration is syntactically ambiguous where the code could be either a declaration of a function pointer accepting no arguments and returning a Widget or a declaration of a local variable of type Widget. The syntax used in this example defines the former instead of the latter.
// #include <iostream>
 
struct Widgetn {
  Widgetn() { std::cout << "Constructed" << std::endl; }
};
 
void fn() {
  Widgetn w();
}

//{C} As a result, this program compiles and prints no output because the default constructor is never actually invoked.
// Compliant Solution
// This compliant solution shows two equally compliant ways to write the declaration. The first way is to elide the parentheses after the variable declaration, which ensures the syntax is that of a variable declaration instead of a function declaration. The second way is to use a braced-init-list to direct-initialize the local variable.
// #include <iostream>
 
struct Widgetc {
  Widgetc() { std::cout << "Constructed" << std::endl; }
};
 
void fc() {
  Widgetc w1; // Elide the parentheses
  Widgetc w2{}; // Use direct initialization
}

//{C} Running this program produces the output Constructed twice, once for w1 and once for w2.
// Noncompliant Code Example
// This noncompliant code example demonstrates a vexing parse. The declaration Gadget g(Widget(i)); is not parsed as declaring a Gadget object with a single argument. It is instead parsed as a function declaration with a redundant set of parentheses around a parameter.
//#include <iostream>
 
struct Widgetn2 {
  explicit Widgetn2(int i) { std::cout << "Widget constructed" << std::endl; }
};
 
struct Gadgetn {
  explicit Gadgetn(Widgetn2 wid) { std::cout << "Gadget constructed" << std::endl; }
};
 
void fn2() {
  int i = 3;
  Gadgetn g(Widgetn2(i));
  std::cout << i << std::endl;
}

// Parentheses around parameter names are optional, so the following is a semantically identical spelling of the declaration.
// Gadget g(Widget i);

//{C} As a result, this program is well-formed and prints only 3 as output because no Gadget or Widget objects are constructed.
// Compliant Solution
// This compliant solution demonstrates two equally compliant ways to write the declaration of g. The first declaration, g1, uses an extra set of parentheses around the argument to the constructor call, forcing the compiler to parse it as a local variable declaration of type Gadget instead of as a function declaration. The second declaration, g2, uses direct initialization to similar effect.
// #include <iostream>
 
struct Widgetc2 {
  explicit Widgetc2(int i) { std::cout << "Widget constructed" << std::endl; }
};
 
struct Gadgetc {
  explicit Gadgetc(Widgetc2 wid) { std::cout << "Gadget constructed" << std::endl; }
};
 
void fc2() {
  int i = 3;
  Gadgetc g1((Widgetc2(i))); // Use extra parentheses
  Gadgetc g2{Widgetc2(i)}; // Use direct initialization
  std::cout << i << std::endl;
}

// Running this program produces the expected output.
// Widget constructed
// Gadget constructed
// Widget constructed
// Gadget constructed
// 3

int main(int count, char ** argv) {
    increment_by_42n();
    increment_by_42c();
    fn();
    fc();
    fn2();
    fc2();
    std::cout << ru << std::endl << rus << std::endl;
    return count;
}

// ver 0.1
//<4.1 clang>
//<4.1.1 warnings>
//DCL53.cpp:114:12: warning: empty parentheses interpreted as a function declaration
//      [-Wvexing-parse]
//  Widgetn w();
//           ^~
//DCL53.cpp:114:12: note: remove parentheses to declare a variable
//  Widgetn w();
//           ^~
//DCL53.cpp:146:12: warning: parentheses were disambiguated as a function declaration
//      [-Wvexing-parse]
//  Gadgetn g(Widgetn2(i));
//           ^~~~~~~~~~~~~
//DCL53.cpp:146:13: note: add a pair of parentheses to declare a variable
//  Gadgetn g(Widgetn2(i));
//            ^
//            (          )
//2 warnings generated.
//<4.1.2 outputs>
// 42
// 84
// Constructed
// Constructed
// 3
// Widget constructed
// Gadget constructed
// Widget constructed
// Gadget constructed
// 3
// Rule 01. Declarations and Initialization (DCL)
// DCL53-CPP. Do not write syntactically ambiguous declarations
//<4.2 gcc6> no warnings and outputs are
// 42
// 84
// Constructed
// Constructed
// 3
// Widget constructed
//Gadget constructed
//Widget constructed
//Gadget constructed
//3
//Rule 01. Declarations and Initialization (DCL)
// DCL53-CPP. Do not write syntactically ambiguous declarations
08:15 | 投票する | 投票数(0) | コメント(0)
2017/09/18new

DCL52-CPP. Never qualify a reference type with const or volatile

Tweet ThisSend to Facebook | by kaizen
// 1 filename: DCL52.cpp
// ver 0.1 18(Mon), Aug, 2017

#include <iostream>
#include <string>
#include <cstdarg>

// 2 original examples and/or notes:
// (c) SEI CERT, C++ Coding standard
// https://www.securecoding.cert.org/confluence/pages/viewpage.action?pageId=637
std::string ru ( "Rule 01. Declarations and Initialization (DCL) ");
std::string rus ( "DCL52-CPP. Never qualify a reference type with const or volatile");
//    David Svoboda Create, 8 01, 2017 G. Ann Campbell Last update
//
// 3 compile and output mechanism:
// (c) Dr. OGAWA Kiyoshi, kaizen at wh.commufa.jp,
//
// 4 compile errors and/or warnings:
// 4.1  Clang  http://www.llvm.org/
// Copyright (c) 2003-2017, LLVM Project
// clang++ --version
// (c) clang version 5.0.0 (tags/RELEASE_500/final)
// Target: x86_64-apple-darwin14.5.0
// Thread model: posix
// InstalledDir: /usr/local/opt/llvm/bin
// Base standard: https://clang.llvm.org/cxx_status.html
// Command/Options: clang++ -std=c++14 -stdlib=libc++ -Wall DCL52.cpp -o DCL52L
// Configuration: brew install --with-clang llvm
//
// 4.2. g++ (Homebrew GCC 6.4.0) 6.4.0
// Copyright (C) 2017 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.
// ln -s /usr/local/bin/gcc-6 /usr/local/bin/gcc
// ln -s /usr/local/bin/g++-6 /usr/local/bin/g++
// Base standard: http://gcc.gnu.org/onlinedocs/gcc/Standards.html
// Command/Options: g++  -std=c++14  -Wall DCL52.cpp  -o DCL52G
// Configuration:brew install gcc6
//
// 5. Hardware:  MacBook Pro,  (Retina, 13-inch, Mid 2014)
// OS X 10.10.5 Yosemite
//Core i5, 2.6GHz, 16GB, 1600MHz DDR3
//(c) Intel http://ark.intel.com/products/series/75024/4th-Generation-Intel-Core-i5-Processors
//
// 6. Special Thanks: Upper organizatios and
// ISO/IEC JTC1 SC22 WG21: http://www.open-std.org/jtc1/sc22/wg21/
// MISRA: https://www.misra.org.uk/forum/index.php
// ISO/IEC JTC1 SC22 WG14: http://www.open-std.org/jtc1/sc22/wg14/
// ITSCJ/IPSJ http://www.itscj.ipsj.or.jp/itscj_english/index.html
// Renesas Electronics Corporation.http://www.renesas.com/
// NPO SESSAME project, http://www.sessame.jp/workinggroup/WorkingGroup3/
// Toyo Corporation, http://www.toyo.co.jp/English/
// Japan Standard Association, http://bit.ly/1lzykg1
// NPO TOPPERS project, https://www.toppers.jp/asp-d-download.html
// Daido Universcity, http://www.daido-it.ac.jp/gakubugakka/computer/index.html
// WITZ Co.Ltd., http://www.witz-inc.co.jp/products/solution/solution.html
// SevenWise.Co., http://www.7ws.co.jp/index.html
// TOYOTA Motor Corporation, http://toyota.jp/
// DENSO Corporation, http://www.globaldenso.com/en/
// Aisin Seiki Co. Ltd., http://www.aisin.com/
// Cypress Semiconductor Corp., http://japan.cypress.com/
// Yazaki Corporation, http://www.yazaki-group.com/global/
// Pananosic Corporation, http://www.panasonic.net/
// Denso Create Inc.: http://www.denso-create.jp
// SWEST: Summer Workshop on Embedded System Technologies , http://swest.toppers.jp
// CEST: Consortium for Embedded System Technology, http://www.ertl.jp/CEST/
// JUSE: Union of Japanese Scientists and Engineers, http://www.juse.or.jp/e/
// OSC: Open Source Conference, http://www.ospn.jp/

// 7. notes
//{C} Cert C++ text
//{L} LLVM warnings and errors
//{G} Gcc warning and errors
//{S} C++ standard, ISO/IEC JTC1 SC22 WG14
// add 'n' to function and variable names of non compliant example if a same name exists. And sequence number also.
// add 'c' to  function and variable names of compliant examples if a same name exists. And sequence number also.
// adding some output command by Dr O.K.

// 8. program and text
//{C} C++ does not allow you to change the value of a reference type, effectively treating all references as being const qualified. The C++ Standard, [dcl.ref], paragraph 1 [ISO/IEC 14882-2014], states the following:
//{S} Cv-qualified references are ill-formed except when the cv-qualifiers are introduced through the use of a typedef-name (7.1.3, 14.1) or decltype-specifier (7.1.6.2), in which case the cv-qualifiers are ignored.

//{C} Thus, C++ prohibits or ignores the cv-qualification of a reference type. Only a value of non-reference type may be cv-qualified.
// When attempting to const-qualify a type as part of a declaration that uses reference type, a programmer may accidentally write
// char &const pn;
//{L} DCL52.cpp:82:7: error: 'const' qualifier may not be applied to a reference
//    DCL52.cpp:82:13: error: declaration of reference variable 'pn' requires an initializer
//{G} DCL52.cpp:82:13: error: 'const' qualifiers cannot be applied to 'char&'
//    DCL52.cpp:82:13: error: 'pn' declared as reference but not initialized

//{C} instead of
 char const &pc ='c' ; // Or: const char &p;
//{L} DCL52.cpp:85:13: error: declaration of reference variable 'pc' requires an initializer
//{G} DCL52.cpp:85:13: error: 'pc' declared as reference but not initialized

//{C} Do not attempt to cv-qualify a reference type because it results in undefined behavior. A conforming compiler is required to issue a diagnostic message. However, if the compiler does not emit a fatal diagnostic, the program may produce surprising results, such as allowing the character referenced by p to be mutated.
//{C} Noncompliant Code Example
// In this noncompliant code example, a const-qualified reference to a char is formed instead of a reference to a const-qualified char. This results in undefined behavior.
// #include <iostream>
 
void f(char c) {
///  char &const p = c; remove with error by Dr. O.K.
  char const &p =c;
///  p = 'p'; remove with error by Dr. O.K.
  std::cout << c << p <<std::endl;
}
//{C} Implementation Details (MSVC)
// With Microsoft Visual Studio 2015, this code compiles successfully with a warning diagnostic.
// warning C4227: anachronism used : qualifiers on reference are ignored
// When run, the code outputs the following.
//    p
// Implementation Details (Clang)
// With Clang 3.9, this code produces a fatal diagnostic.
// error: 'const' qualifier may not be applied to a reference
//{L} DCL52.cpp:99:9: error: 'const' qualifier may not be applied to a reference
//{G} DCL52.cpp:99:15: error: 'const' qualifiers cannot be applied to 'char&'

//{C} Noncompliant Code Example
// This noncompliant code example correctly declares p to be a reference to a const-qualified char. The subsequent modification of p makes the program ill-formed.
// #include <iostream>
 
void fn(char c) {
  const char &p = c;
///  p = 'p'; // Error: read-only variable is not assignable; remove with error by Dr. O.K.
    std::cout << " fn: "<< c << p << std::endl;
}
//{L} DCL52.cpp:121:5: error: cannot assign to variable 'p' with const-qualified type
//      'const char &'
//  p = 'p'; // Error: read-only variable is not assignable
//  ~ ^
//{G}  DCL52.cpp:121:7: error: assignment of read-only reference 'p'
//   p = 'p'; // Error: read-only variable is not assignable
//       ^~~
//{C} Compliant Solution
// This compliant solution removes the const qualifier.
// #include <iostream>
 
void fc(char c) {
  char &p = c;
  p = 'p';
    std::cout <<" fc: "<< c << std::endl;
}

int main(int count, char ** argv) {
    char c = 'c';
    char n = 'n';
    f(c);
    fn(n);
    fc(c);
    std::cout << ru << std::endl << rus << std::endl;
    return count;
}
// ver 0.1
// 4.1 clang
// cc
// fn: nn
// fc: p
// Rule 01. Declarations and Initialization (DCL)
// DCL52-CPP. Never qualify a reference type with const or volatile
// 4.2 gcc6
// cc
// fn: nn
// fc: p
// Rule 01. Declarations and Initialization (DCL)
// DCL52-CPP. Never qualify a reference type with const or volatile
07:37 | 投票する | 投票数(0) | コメント(0)
2017/09/18new

DCL50-CPP. Do not define a C-style variadic function

Tweet ThisSend to Facebook | by kaizen
// 1 filename: DCL50.cpp
// ver 0.1 16(Sat), Aug, 2017
// ver 0.2 17(Sun), Aug, 2017
// ver 0.3 18(Mon), Aug, 2017
//
// 2 original examples and/or notes:
// (c) SEI CERT, C++ Coding standard
// https://www.securecoding.cert.org/confluence/pages/viewpage.action?pageId=637
//Rule 01. Declarations and Initialization (DCL)
//DCL50-CPP. Do not define a C-style variadic function
//Dan Saks, 8 01, 2017  G. Ann Campbell
//
// 3 compile and output mechanism:
// (c) Dr. OGAWA Kiyoshi, kaizen at wh.commufa.jp,
//
// 4 compile errors and/or warnings:
// 4.1  Clang  http://www.llvm.org/
// Copyright (c) 2003-2017, LLVM Project
// clang++ --version
// (c) clang version 5.0.0 (tags/RELEASE_500/final)
// Target: x86_64-apple-darwin14.5.0
// Thread model: posix
// InstalledDir: /usr/local/opt/llvm/bin
// Base standard: https://clang.llvm.org/cxx_status.html
// Command/Options: clang++ -std=c++14 -stdlib=libc++ -Wall DCL50.cpp -o DCL50L
// Configuration: brew install --with-clang llvm
//
// 4.2. g++ (Homebrew GCC 6.4.0) 6.4.0
// Copyright (C) 2017 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.
// ln -s /usr/local/bin/gcc-6 /usr/local/bin/gcc
// ln -s /usr/local/bin/g++-6 /usr/local/bin/g++
// Base standard: http://gcc.gnu.org/onlinedocs/gcc/Standards.html
// Command/Options: g++  -std=c++14  -Wall DCL50.cpp  -o DCL50G
// Configuration:brew install gcc6
//
// 5. Hardware:  MacBook Pro,  (Retina, 13-inch, Mid 2014)
// OS X 10.10.5 Yosemite
//Core i5, 2.6GHz, 16GB, 1600MHz DDR3
//(c) Intel http://ark.intel.com/products/series/75024/4th-Generation-Intel-Core-i5-Processors
//
// 6. Special Thanks: Upper organizatios and
// ISO/IEC JTC1 SC22 WG21: http://www.open-std.org/jtc1/sc22/wg21/
// MISRA: https://www.misra.org.uk/forum/index.php
// ISO/IEC JTC1 SC22 WG14: http://www.open-std.org/jtc1/sc22/wg14/
// ITSCJ/IPSJ http://www.itscj.ipsj.or.jp/itscj_english/index.html
// Renesas Electronics Corporation.http://www.renesas.com/
// NPO SESSAME project, http://www.sessame.jp/workinggroup/WorkingGroup3/
// Toyo Corporation, http://www.toyo.co.jp/English/
// Japan Standard Association, http://bit.ly/1lzykg1
// NPO TOPPERS project, https://www.toppers.jp/asp-d-download.html
// Daido Universcity, http://www.daido-it.ac.jp/gakubugakka/computer/index.html
// WITZ Co.Ltd., http://www.witz-inc.co.jp/products/solution/solution.html
// SevenWise.Co., http://www.7ws.co.jp/index.html
// TOYOTA Motor Corporation, http://toyota.jp/
// DENSO Corporation, http://www.globaldenso.com/en/
// Aisin Seiki Co. Ltd., http://www.aisin.com/
// Cypress Semiconductor Corp., http://japan.cypress.com/
// Yazaki Corporation, http://www.yazaki-group.com/global/
// Pananosic Corporation, http://www.panasonic.net/
// Denso Create Inc.: http://www.denso-create.jp
// SWEST: Summer Workshop on Embedded System Technologies , http://swest.toppers.jp
// CEST: Consortium for Embedded System Technology, http://www.ertl.jp/CEST/
// JUSE: Union of Japanese Scientists and Engineers, http://www.juse.or.jp/e/
// OSC: Open Source Conference, http://www.ospn.jp/

// 7. notes
//{C} Cert C++ text
//{L} LLVM warnings and errors
//{G} Gcc warning and errors

// 8. program and text
//{C} Functions can be defined to accept more formal arguments at the call site than are specified by the parameter declaration clause. Such functions are called variadic functions because they can accept a variable number of arguments from a caller. C++ provides two mechanisms by which a variadic function can be defined: function parameter packs and use of a C-style ellipsis as the final parameter declaration.
// Variadic functions are flexible because they accept a varying number of arguments of differing types. However, they can also be hazardous. A variadic function using a C-style ellipsis (hereafter called a C-style variadic function) has no mechanisms to check the type safety of arguments being passed to the function or to check that the number of arguments being passed matches the semantics of the function definition. Consequently, a runtime call to a C-style variadic function that passes inappropriate arguments yields undefined behavior. Such undefined behavior could be exploited to run arbitrary code.
// Do not define C-style variadic functions. (The declaration of a C-style variadic function that is never defined is permitted, as it is not harmful and can be useful in unevaluated contexts.)
// Issues with C-style variadic functions can be avoided by using variadic functions defined with function parameter packs for situations in which a variable number of arguments should be passed to a function. Additionally, function currying can be used as a replacement to variadic functions. For example, in contrast to C's printf() family of functions, C++ output is implemented with the overloaded single-argument std::cout::operator<<() operators.
#include <iostream>
#include <string>
#include <cstdarg>

//{C} Noncompliant Code Example
// This noncompliant code example uses a C-style variadic function to add a series of integers together. The function reads arguments until the value 0 is found. Calling this function without passing the value 0 as an argument (after the first two arguments) results in undefined behavior. Furthermore, passing any type other than an int also results in undefined behavior.

int add(int first, int second, ...) {
  int r = first + second;
  va_list va;
  va_start(va, second);
  while (int v = va_arg(va, int)) {
    r += v;
  }
  va_end(va);
  return r;
}

//{C} Compliant Solution (Recursive Pack Expansion)
// In this compliant solution, a variadic function using a function parameter pack is used to implement the add() function, allowing identical behavior for call sites. Unlike the C-style variadic function used in the noncompliant code example, this compliant solution does not result in undefined behavior if the list of parameters is not terminated with 0. Additionally, if any of the values passed to the function are not integers, the code is ill-formed rather than producing undefined behavior.
#include <type_traits>
 
template <typename Arg, typename std::enable_if<std::is_integral<Arg>::value>::type * = nullptr>
int add2(Arg f, Arg s) { return f + s; }
 
//template <typename Arg, typename... Ts, typename std::enable_if<std::is_integral<Arg>::value>::type * = nullptr>
//int add3(Arg f, Ts... rest) {
//  return f + add3(rest...);
//}

//{C} This compliant solution makes use of std::enable_if to ensure that any nonintegral argument value results in an ill-formed program.
// Compliant Solution (Braced Initializer List Expansion)
// An alternative compliant solution that does not require recursive expansion of the function parameter pack instead expands the function parameter pack into a list of values as part of a braced initializer list. Since narrowing conversions are not allowed in a braced initializer list, the type safety is preserved despite the std::enable_if not involving any of the variadic arguments.
// #include <type_traits>
 
template <typename Arg, typename... Ts, typename std::enable_if<std::is_integral<Arg>::value>::type * = nullptr>
int add4(Arg i, Arg j, Ts... all) {
  int values[] = { j, all... };
  int r = i;
  for (auto v : values) {
    r += v;
  }
  return r;
}

//{C} Exceptions
// DCL50-CPP-EX1: It is permissible to define a C-style variadic function if that function also has external C language linkage. For instance, the function may be a definition used in a C library API that is implemented in C++.
// DCL50-CPP-EX2: As stated in the normative text, C-style variadic functions that are declared but never defined are permitted. For example, when a function call expression appears in an unevaluated context, such as the argument in a sizeof expression, overload resolution is performed to determine the result type of the call but does not require a function definition. Some template metaprogramming techniques that employ SFINAE use variadic function declarations to implement compile-time type queries, as in the following example.

template <typename Ty>
class has_foo_function {
  typedef char yes[1];
  typedef char no[2];
 
  template <typename Inner>
  static yes& test(Inner *I, decltype(I->foo()) * = nullptr); // Function is never defined.
 
  template <typename>
  static no& test(...); // Function is never defined.
 
public:
  static const bool value = sizeof(test<Ty>(nullptr)) == sizeof(yes);
};
      
//{C} In this example, the value of value is determined on the basis of which overload of test() is selected. The declaration of Inner *I allows use of the variable I within the decltype specifier, which results in a pointer of some (possibly void) type, with a default value of nullptr. However, if there is no declaration of Inner::foo(), the decltype specifier will be ill-formed, and that variant of test() will not be a candidate function for overload resolution due to SFINAE. The result is that the C-style variadic function variant of test() will be the only function in the candidate set. Both test() functions are declared but never defined because their definitions are not required for use within an unevaluated expression context.
 
int main(int count, char ** argv) {
    int a = 2;
    int b = 4;
    int d = 8;
    int r1 = add(count, a); // add ver.0.2
    int r2 = add2<int>(count, b);
//    int r3 = add3<int>(count, c);
    int r4 = add4<int>(count,d);
    std::cout << " r1:"<< r1 << " r2:"<<r2 <<" r4:"<<r4;
    return r1;
}

// ver 0.1 remove ver0.2 and 6 //comments.
//./a.out
// Segmentation fault: 11
// ver0.2
// 4.1 clang
// r1:1482291389 r2:7 r4:15
// 4.2 gcc6
// r1:-1609846149 r2:7 r4:15
// ver 0.3
// r1:-1204923781 r2:5 r4:9
// 4.2 gcc6
// r1:1519180213 r2:5 r4:9
04:11 | 投票する | 投票数(0) | コメント(0)
2017/09/17new

cpp template

Tweet ThisSend to Facebook | by kaizen
#include <iostream>
#include <string>
#include <cstdarg>
#include <type_traits>
 
template <typename Arg, typename std::enable_if<std::is_integral<Arg>::value>::type * = nullptr>
int add2(Arg f, Arg s) { return f + s; }
 
template <typename Arg, typename... Ts, typename std::enable_if<std::is_integral<Arg>::value>::type * = nullptr>
int add3(Arg f, Ts... rest) {
  return f + add3(rest...);
}
 
int add(int first, int second, ...) {
  int r = first + second;
  va_list va;
  va_start(va, second);
  while (int v = va_arg(va, int)) {
    r += v;
  }
  va_end(va);
  return r;
}

int main(int count, char ** argv) {
    int r1 = add(1,  2); // add ver.0.2
    int r2 = add2(3, 4);
    int r3 = add3(5, 6);
    std::cout << r <<r2 <<r3;
    return r;
}

 g++  -std=c++14  -Wall50 DCL
DCL50.cpp: In function 'int main(int, char**)':
DCL50.cpp:115:15: error: 'r' was not declared in this scope
  std::cout << r <<r2 <<r3;
               ^
DCL50.cpp:112:6: warning: unused variable 'r1' [-Wunused-variable]
  int r1 = add(1, 2); // add ver.0.2
      ^~
DCL50.cpp: In instantiation of 'int add3(Arg, Ts ...) [with Arg = int; Ts = {}; typename std::enable_if<std::is_integral<_Tp>::value>::type* <anonymous> = 0u]':
DCL50.cpp:87:18:   required from 'int add3(Arg, Ts ...) [with Arg = int; Ts = {int}; typename std::enable_if<std::is_integral<_Tp>::value>::type* <anonymous> = 0u]'
DCL50.cpp:114:19:   required from here
DCL50.cpp:87:18: error: no matching function for call to 'add3()'
   return f + add3(rest...);
              ~~~~^~~~~~~~~
DCL50.cpp:86:5: note: candidate: template<class Arg, class ... Ts, typename std::enable_if<std::is_integral<_Tp>::value>::type* <anonymous> > int add3(Arg, Ts ...)
 int add3(Arg f, Ts... rest) {
     ^~~~
DCL50.cpp:86:5: note:   template argument deduction/substitution failed:
DCL50.cpp:87:18: note:   candidate expects at least 1 argument, 0 provided
   return f + add3(rest...);
              ~~~~^~~~~~~~~


#include <iostream>
#include <string>
#include <cstdarg>
#include <type_traits>
 
template <typename Arg, typename std::enable_if<std::is_integral<Arg>::value>::type * = nullptr>
int add2(Arg f, Arg s) { return f + s; }
 
template <typename Arg, typename... Ts, typename std::enable_if<std::is_integral<Arg>::value>::type * = nullptr>
int add3(Arg f, Ts... rest) {
  return f + add3(rest...);
}
 
int add(int first, int second, ...) {
  int r = first + second;
  va_list va;
  va_start(va, second);
  while (int v = va_arg(va, int)) {
    r += v;
  }
  va_end(va);
  return r;
}

int main(int count, char ** argv) {
    int r1 = add(1,  2); // add ver.0.2
    int r2 = add2(3, 4);
    int r3 = add3(5, 6);
    std::cout << r1 <<r2 <<r3;
    return r1 ;
}

 g++  -std=c++14  -Wall DCL50.cpp
DCL50.cpp: In instantiation of 'int add3(Arg, Ts ...) [with Arg = int; Ts = {}; typename std::enable_if<std::is_integral<_Tp>::value>::type* <anonymous> = 0u]':
DCL50.cpp:87:18:   required from 'int add3(Arg, Ts ...) [with Arg = int; Ts = {int}; typename std::enable_if<std::is_integral<_Tp>::value>::type* <anonymous> = 0u]'
DCL50.cpp:114:19:   required from here
DCL50.cpp:87:18: error: no matching function for call to 'add3()'
   return f + add3(rest...);
              ~~~~^~~~~~~~~
DCL50.cpp:86:5: note: candidate: template<class Arg, class ... Ts, typename std::enable_if<std::is_integral<_Tp>::value>::type* <anonymous> > int add3(Arg, Ts ...)
 int add3(Arg f, Ts... rest) {
     ^~~~
DCL50.cpp:86:5: note:   template argument deduction/substitution failed:
DCL50.cpp:87:18: note:   candidate expects at least 1 argument, 0 provided
   return f + add3(rest...);
              ~~~~^~~~~~~~~


#include <iostream>
#include <string>
#include <cstdarg>
#include <type_traits>
 
template <typename Arg, typename std::enable_if<std::is_integral<Arg>::value>::type * = nullptr>
int add2(Arg f, Arg s) { return f + s; }
 
template <typename Arg, typename... Ts, typename std::enable_if<std::is_integral<Arg>::value>::type * = nullptr>
int add3(Arg f, Ts... rest) {
  return f + add3(rest...);
}
 
int add(int first, int second, ...) {
  int r = first + second;
  va_list va;
  va_start(va, second);
  while (int v = va_arg(va, int)) {
    r += v;
  }
  va_end(va);
  return r;
}

int main(int count, char ** argv) {
    int r1 = add(1,  2); // add ver.0.2
    int r2 = add2<int>(3, 4);
    int r3 = add3<int>(5, 6);
    std::cout << r1 <<r2 <<r3;
    return r1;
}
19:20 | 投票する | 投票数(0) | コメント(0)
2017/09/17new

DCL50-CPP. Do not define a C-style variadic function

Tweet ThisSend to Facebook | by kaizen
// 1 filename: DCL50.cpp
// ver 0.2 17(Sun), Aug, 2017
//
// 2 original examples and/or notes:
// (c) SEI CERT, C++ Coding standard
// https://www.securecoding.cert.org/confluence/pages/viewpage.action?pageId=637
//Rule 01. Declarations and Initialization (DCL)
//DCL50-CPP. Do not define a C-style variadic function
//Dan Saks, 8 01, 2017  G. Ann Campbell
//
// 3 compile and output mechanism:
// (c) Dr. OGAWA Kiyoshi, kaizen at wh.commufa.jp,
//
// 4 compile errors and/or warnings:
// 4.1  Clang  
// clang++ --version
// (c) clang version 5.0.0 (tags/RELEASE_500/final)
// Target: x86_64-apple-darwin14.5.0
// Thread model: posix
// InstalledDir: /usr/local/opt/llvm/bin
// Target: x86_64-apple-darwin13.2.0,  Thread model: posix
// Command/Options: clang++ -std=c++14 -stdlib=libc++ -Wall DCL50.cpp -o DCL50L
// (c) Copyright 2003-2017, LLVM Project
// Configuration: brew install --with-clang llvm
//
// 4.2. g++ (Homebrew GCC 6.4.0) 6.4.0
// Copyright (C) 2017 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.
// http://gcc.gnu.org/onlinedocs/gcc/Standards.html
// ln -s /usr/local/bin/gcc-6 /usr/local/bin/gcc
// ln -s /usr/local/bin/g++-6 /usr/local/bin/g++
// Command/Options: g++  -std=c++14  -Wall DCL50.cpp  -o DCL50G
// Configuration:brew install gcc6
//
// 5. Hardware:  MacBook Pro,  (Retina, 13-inch, Mid 2014)
// OS X 10.10.5 Yosemite
//(c) Intel http://ark.intel.com/products/series/75024/4th-Generation-Intel-Core-i5-Processors
//Core i5, 2.6GHz, 16GB, 1600MHz DDR3
//
// 6. Special Thanks: Upper organizatios and
// CERT CPP: https://www.securecoding.cert.org/confluence/pages/viewpage.action?pageId=637
// ISO/IEC JTC1 SC22 WG21: http://www.open-std.org/jtc1/sc22/wg21/
// MISRA: https://www.misra.org.uk/forum/index.php
// ISO/IEC JTC1 SC22 WG14: http://www.open-std.org/jtc1/sc22/wg14/
// ITSCJ/IPSJ http://www.itscj.ipsj.or.jp/itscj_english/index.html
// Renesas Electronics Corporation.http://www.renesas.com/
// NPO SESSAME project, http://www.sessame.jp/workinggroup/WorkingGroup3/
// Toyo Corporation, http://www.toyo.co.jp/English/
// Japan Standard Association, http://bit.ly/1lzykg1
// NPO TOPPERS project, https://www.toppers.jp/asp-d-download.html
// Daido Universcity, http://www.daido-it.ac.jp/gakubugakka/computer/index.html
// WITZ Co.Ltd., http://www.witz-inc.co.jp/products/solution/solution.html
// SevenWise.co., http://www.7ws.co.jp/index.html
// TOYOTA Motor Corporation, http://toyota.jp/
// DENSO Corporation, http://www.globaldenso.com/en/
// Aisin Seiki co. Ltd., http://www.aisin.com/
// Spancion Inc., http://www.spansion.com/
// Yazaki Corporation, http://www.yazaki-group.com/global/
// Pananosic Corporation, http://www.panasonic.net/
// SWEST: Summer Workshop on Embedded System Technologies , http://swest.toppers.jp
// CEST: Consortium for Embedded System Technology, http://www.ertl.jp/CEST/
// JUSE: Union of Japanese Scientists and Engineers, http://www.juse.or.jp/e/
// OSC:Open Source Conference, http://www.ospn.jp/
// Denso Create: http://www.denso-create.jp

//Functions can be defined to accept more formal arguments at the call site than are specified by the parameter declaration clause. Such functions are called variadic functions because they can accept a variable number of arguments from a caller. C++ provides two mechanisms by which a variadic function can be defined: function parameter packs and use of a C-style ellipsis as the final parameter declaration.
//Variadic functions are flexible because they accept a varying number of arguments of differing types. However, they can also be hazardous. A variadic function using a C-style ellipsis (hereafter called a C-style variadic function) has no mechanisms to check the type safety of arguments being passed to the function or to check that the number of arguments being passed matches the semantics of the function definition. Consequently, a runtime call to a C-style variadic function that passes inappropriate arguments yields undefined behavior. Such undefined behavior could be exploited to run arbitrary code.
//Do not define C-style variadic functions. (The declaration of a C-style variadic function that is never defined is permitted, as it is not harmful and can be useful in unevaluated contexts.)
//Issues with C-style variadic functions can be avoided by using variadic functions defined with function parameter packs for situations in which a variable number of arguments should be passed to a function. Additionally, function currying can be used as a replacement to variadic functions. For example, in contrast to C's printf() family of functions, C++ output is implemented with the overloaded single-argument std::cout::operator<<() operators.
#include <iostream>
#include <string>
#include <cstdarg>

//Noncompliant Code Example
//This noncompliant code example uses a C-style variadic function to add a series of integers together. The function reads arguments until the value 0 is found. Calling this function without passing the value 0 as an argument (after the first two arguments) results in undefined behavior. Furthermore, passing any type other than an int also results in undefined behavior.
//

int add(int first, int second, ...) {
  int r = first + second;
  va_list va;
  va_start(va, second);
  while (int v = va_arg(va, int)) {
    r += v;
  }
  va_end(va);
  return r;
}


//Compliant Solution (Recursive Pack Expansion)

//In this compliant solution, a variadic function using a function parameter pack is used to implement the add() function, allowing identical behavior for call sites. Unlike the C-style variadic function used in the noncompliant code example, this compliant solution does not result in undefined behavior if the list of parameters is not terminated with 0. Additionally, if any of the values passed to the function are not integers, the code is ill-formed rather than producing undefined behavior.
#include <type_traits>
 
template <typename Arg, typename std::enable_if<std::is_integral<Arg>::value>::type * = nullptr>
int add2(Arg f, Arg s) { return f + s; }
 
//template <typename Arg, typename... Ts, typename std::enable_if<std::is_integral<Arg>::value>::type * = nullptr>
//int add3(Arg f, Ts... rest) {
//  return f + add3(rest...);
//}

//This compliant solution makes use of std::enable_if to ensure that any nonintegral argument value results in an ill-formed program.

//Compliant Solution (Braced Initializer List Expansion)

//An alternative compliant solution that does not require recursive expansion of the function parameter pack instead expands the function parameter pack into a list of values as part of a braced initializer list. Since narrowing conversions are not allowed in a braced initializer list, the type safety is preserved despite the std::enable_if not involving any of the variadic arguments.
// #include <type_traits>
 
template <typename Arg, typename... Ts, typename std::enable_if<std::is_integral<Arg>::value>::type * = nullptr>
int add4(Arg i, Arg j, Ts... all) {
  int values[] = { j, all... };
  int r = i;
  for (auto v : values) {
    r += v;
  }
  return r;
}

//Exceptions
// DCL50-CPP-EX1: It is permissible to define a C-style variadic function if that function also has external C language linkage. For instance, the function may be a definition used in a C library API that is implemented in C++.
// DCL50-CPP-EX2: As stated in the normative text, C-style variadic functions that are declared but never defined are permitted. For example, when a function call expression appears in an unevaluated context, such as the argument in a sizeof expression, overload resolution is performed to determine the result type of the call but does not require a function definition. Some template metaprogramming techniques that employ SFINAE use variadic function declarations to implement compile-time type queries, as in the following example.

template <typename Ty>
class has_foo_function {
  typedef char yes[1];
  typedef char no[2];
 
  template <typename Inner>
  static yes& test(Inner *I, decltype(I->foo()) * = nullptr); // Function is never defined.
 
  template <typename>
  static no& test(...); // Function is never defined.
 
public:
  static const bool value = sizeof(test<Ty>(nullptr)) == sizeof(yes);
};

//In this example, the value of value is determined on the basis of which overload of test() is selected. The declaration of Inner *I allows use of the variable I within the decltype specifier, which results in a pointer of some (possibly void) type, with a default value of nullptr. However, if there is no declaration of Inner::foo(), the decltype specifier will be ill-formed, and that variant of test() will not be a candidate function for overload resolution due to SFINAE. The result is that the C-style variadic function variant of test() will be the only function in the candidate set. Both test() functions are declared but never defined because their definitions are not required for use within an unevaluated expression context.
 
int main(int count, char ** argv) {
    int r1 = add(1, 2); // add ver.0.2
    int r2 = add2<int>(3, 4);
//    int r3 = add3<int>(5, 6);
    int r4 = add4<int>(7,8);
    std::cout << "r1:"<< r1 << "r2:"<<r2 <<"r4:"<<r4;
    return r1;
}
// ver 0.1 remove ver0.2 and 6 //comments.
//./a.out
// Segmentation fault: 11
// ver0.2
// 4.1 clang
// r1:1482291389 r2:7 r4:15
// 4.2 gcc6
// r1:-1609846149 r2:7 r4:15
19:11 | 投票する | 投票数(0) | コメント(0)
2017/09/17new

macにgccgをインストール

Tweet ThisSend to Facebook | by kaizen
http://qiita.com/akameco/items/b081f05757eef4360108

ln -s /usr/local/bin/gcc-5 /usr/local/bin/gcc
ln -s /usr/local/bin/g++-5 /usr/local/bin/g++


brew brew install gcc6
Error: Unknown command: brew
OgawaKiyoshi-no-MacBook-Pro:~ ogawakiyoshi$ brew install gcc6
==> Installing dependencies for gcc@6: mpfr, libmpc, isl
==> Installing gcc@6 dependency: mpfr
==> Downloading https://homebrew.bintray.com/bottles/mpfr-3.1.6.yosemite.bottle.tar.gz
######################################################################## 100.0%
==> Pouring mpfr-3.1.6.yosemite.bottle.tar.gz
????  /usr/local/Cellar/mpfr/3.1.6: 26 files, 3.6MB
==> Installing gcc@6 dependency: libmpc
==> Downloading https://homebrew.bintray.com/bottles/libmpc-1.0.3_1.yosemite.bottle.tar.gz
######################################################################## 100.0%
==> Pouring libmpc-1.0.3_1.yosemite.bottle.tar.gz
????  /usr/local/Cellar/libmpc/1.0.3_1: 12 files, 351.6KB
==> Installing gcc@6 dependency: isl
==> Downloading https://homebrew.bintray.com/bottles/isl-0.18.yosemite.bottle.tar.gz
######################################################################## 100.0%
==> Pouring isl-0.18.yosemite.bottle.tar.gz
????  /usr/local/Cellar/isl/0.18: 80 files, 3.8MB
==> Installing gcc@6
==> Downloading https://homebrew.bintray.com/bottles/gcc@6-6.4.0.yosemite.bottle.tar.gz
######################################################################## 100.0%
==> Pouring gcc@6-6.4.0.yosemite.bottle.tar.gz
????  /usr/local/Cellar/gcc@6/6.4.0: 1,438 files, 281.4MB
18:31 | 投票する | 投票数(0) | コメント(0)
2017/09/17new

virtualenv, llvm test

Tweet ThisSend to Facebook | by kaizen
http://llvm.org/docs/lnt/quickstart.html

----------------- macintosh

Macでpyenv+virtualenv

 brew install pyenv-virtualenv

==> Installing dependencies for pyenv-virtualenv: pyenv
==> Installing pyenv-virtualenv dependency: pyenv
==> Downloading https://homebrew.bintray.com/bottles/pyenv-1.1.3.yosemite.bottle.tar.gz
######################################################################## 100.0%
==> Pouring pyenv-1.1.3.yosemite.bottle.tar.gz
???? /usr/local/Cellar/pyenv/1.1.3: 581 files, 2.2MB
==> Installing pyenv-virtualenv
==> Downloading https://github.com/yyuu/pyenv-virtualenv/archive/v1.1.0.tar.gz
==> Downloading from https://github.com/pyenv/pyenv-virtualenv/archive/v1.1.0.tar.gz
######################################################################## 100.0%
==> ./install.sh
==> Caveats
To enable auto-activation add to your profile:
if which pyenv-virtualenv-init > /dev/null; then eval "$(pyenv virtualenv-init -)"; fi
==> Summary
???? /usr/local/Cellar/pyenv-virtualenv/1.1.0: 20 files, 60.2KB, built in 3 minutes 38 seconds



brew install subversion
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 1 tap (caskroom/cask).
No changes to formulae.

==> Installing dependencies for subversion: perl, apr, apr-util, sqlite
==> Installing subversion dependency: perl
==> Downloading https://homebrew.bintray.com/bottles/perl-5.26.0.yosemite.bottle.tar.gz
######################################################################## 100.0%
==> Pouring perl-5.26.0.yosemite.bottle.tar.gz
==> Caveats
By default non-brewed cpan modules are installed to the Cellar. If you wish
for your modules to persist across updates we recommend using `local::lib`.

You can set that up like this:
  PERL_MM_OPT="INSTALL_BASE=$HOME/perl5" cpan local::lib
  echo 'eval "$(perl -I$HOME/perl5/lib/perl5 -Mlocal::lib)"' >> ~/.bash_profile
==> Summary
????  /usr/local/Cellar/perl/5.26.0: 2,389 files, 57.3MB
==> Installing subversion dependency: apr
==> Downloading https://homebrew.bintray.com/bottles/apr-1.6.2_1.yosemite.bottle.tar.gz
######################################################################## 100.0%
==> Pouring apr-1.6.2_1.yosemite.bottle.tar.gz
==> Caveats
This formula is keg-only, which means it was not symlinked into /usr/local,
because Apple's CLT package contains apr.

If you need to have this software first in your PATH run:
  echo 'export PATH="/usr/local/opt/apr/bin:$PATH"' >> ~/.bash_profile

==> Summary
????  /usr/local/Cellar/apr/1.6.2_1: 60 files, 1.3MB
==> Installing subversion dependency: apr-util
==> Downloading https://homebrew.bintray.com/bottles/apr-util-1.6.0_1.yosemite.bottle.tar.g
######################################################################## 100.0%
==> Pouring apr-util-1.6.0_1.yosemite.bottle.tar.gz
==> Caveats
This formula is keg-only, which means it was not symlinked into /usr/local,
because Apple's CLT package contains apr.

If you need to have this software first in your PATH run:
  echo 'export PATH="/usr/local/opt/apr-util/bin:$PATH"' >> ~/.bash_profile

==> Summary
????  /usr/local/Cellar/apr-util/1.6.0_1: 54 files, 779.3KB
==> Installing subversion dependency: sqlite
==> Downloading https://homebrew.bintray.com/bottles/sqlite-3.20.1.yosemite.bottle.tar.gz
######################################################################## 100.0%
==> Pouring sqlite-3.20.1.yosemite.bottle.tar.gz
==> Caveats
This formula is keg-only, which means it was not symlinked into /usr/local,
because macOS provides an older sqlite3.

If you need to have this software first in your PATH run:
  echo 'export PATH="/usr/local/opt/sqlite/bin:$PATH"' >> ~/.bash_profile

For compilers to find this software you may need to set:
    LDFLAGS:  -L/usr/local/opt/sqlite/lib
    CPPFLAGS: -I/usr/local/opt/sqlite/include
For pkg-config to find this software you may need to set:
    PKG_CONFIG_PATH: /usr/local/opt/sqlite/lib/pkgconfig

==> Summary
????  /usr/local/Cellar/sqlite/3.20.1: 11 files, 3MB
==> Installing subversion
==> Downloading https://homebrew.bintray.com/bottles/subversion-1.9.7.yosemite.bottle.tar.g
######################################################################## 100.0%
==> Pouring subversion-1.9.7.yosemite.bottle.tar.gz
==> Caveats
svntools have been installed to:
  /usr/local/opt/subversion/libexec

The perl bindings are located in various subdirectories of:
  /usr/local/opt/subversion/lib/perl5

If you wish to use the Ruby bindings you may need to add:
  /usr/local/lib/ruby
to your RUBYLIB.

Bash completion has been installed to:
  /usr/local/etc/bash_completion.d
==> Summary
????  /usr/local/Cellar/subversion/1.9.7: 203 files, 22.3MB
OgawaKiyoshi-no-MacBook-Pro:llvm-build ogawakiyoshi$

--
svn co http://llvm.org/svn/llvm-project/lnt/trunk ~/lnt

A    /Users/ogawakiyoshi/lnt/examples
A    /Users/ogawakiyoshi/lnt/deployment
A    /Users/ogawakiyoshi/lnt/schemas
A    /Users/ogawakiyoshi/lnt/docs
A    /Users/ogawakiyoshi/lnt/docs/_templates
A    /Users/ogawakiyoshi/lnt/docs/modules
A    /Users/ogawakiyoshi/lnt/lnt
A    /Users/ogawakiyoshi/lnt/lnt/external
A    /Users/ogawakiyoshi/lnt/lnt/external/stats
A    /Users/ogawakiyoshi/lnt/lnt/tests
A    /Users/ogawakiyoshi/lnt/lnt/server
A    /Users/ogawakiyoshi/lnt/lnt/server/db
A    /Users/ogawakiyoshi/lnt/examples/run_to_csv.py
A    /Users/ogawakiyoshi/lnt/examples/functions.py
A    /Users/ogawakiyoshi/lnt/requirements.client.txt
A    /Users/ogawakiyoshi/lnt/lnt/tests/compile.py
A    /Users/ogawakiyoshi/lnt/lnt/server/db/rules
A    /Users/ogawakiyoshi/lnt/docs/make.bat
A    /Users/ogawakiyoshi/lnt/deployment/app_wrapper.py
A    /Users/ogawakiyoshi/lnt/README.md
A    /Users/ogawakiyoshi/lnt/lnt/external/stats/README.txt
A    /Users/ogawakiyoshi/lnt/schemas/compile.yaml
A    /Users/ogawakiyoshi/lnt/schemas/README.md
A    /Users/ogawakiyoshi/lnt/lnt/server/db/migrations
A    /Users/ogawakiyoshi/lnt/setup.py
A    /Users/ogawakiyoshi/lnt/docs/profiles.rst
A    /Users/ogawakiyoshi/lnt/lnt/tests/nt.py
A    /Users/ogawakiyoshi/lnt/lnt/server/db/testsuitedb.py
A    /Users/ogawakiyoshi/lnt/lnt/server/db/fieldchange.py
A    /Users/ogawakiyoshi/lnt/lnt/server/db/rules/rule_blacklist_benchmarks_by_name.py
A    /Users/ogawakiyoshi/lnt/docs/schema-example.yaml
A    /Users/ogawakiyoshi/lnt/docs/_templates/layout.html
A    /Users/ogawakiyoshi/lnt/docs/_templates/indexsidebar.html
A    /Users/ogawakiyoshi/lnt/docs/_templates/index.html
A    /Users/ogawakiyoshi/lnt/docs/quickstart.rst
A    /Users/ogawakiyoshi/lnt/lnt/server/db/__init__.py
A    /Users/ogawakiyoshi/lnt/lnt/server/db/rules_manager.py
A    /Users/ogawakiyoshi/lnt/lnt/external/stats/stats.py
A    /Users/ogawakiyoshi/lnt/lnt/tests/builtintest.py
A    /Users/ogawakiyoshi/lnt/docs/intro.rst
A    /Users/ogawakiyoshi/lnt/lnt/server/db/rules/__init__.py
A    /Users/ogawakiyoshi/lnt/lnt/server/db/rules/rule_update_fixed_regressions.py
A    /Users/ogawakiyoshi/lnt/lnt/tests/__init__.py
A    /Users/ogawakiyoshi/lnt/lnt/server/reporting
A    /Users/ogawakiyoshi/lnt/lnt/server/db/migrations/upgrade_11_to_12.py
A    /Users/ogawakiyoshi/lnt/lnt/server/db/migrations/__init__.py
A    /Users/ogawakiyoshi/lnt/lnt/server/db/migrate.py
A    /Users/ogawakiyoshi/lnt/lnt/server/db/util.py
A    /Users/ogawakiyoshi/lnt/docs/contents.rst
A    /Users/ogawakiyoshi/lnt/docs/tools.rst
A    /Users/ogawakiyoshi/lnt/lnt/server/db/migrations/upgrade_1_to_2.py
A    /Users/ogawakiyoshi/lnt/lnt/server/db/migrations/upgrade_3_to_4.py
A    /Users/ogawakiyoshi/lnt/lnt/server/db/migrations/new_suite.py
A    /Users/ogawakiyoshi/lnt/lnt/server/db/migrations/upgrade_14_to_15.py
A    /Users/ogawakiyoshi/lnt/lnt/server/db/migrations/upgrade_8_to_9.py
A    /Users/ogawakiyoshi/lnt/lnt/server/db/regression.py
A    /Users/ogawakiyoshi/lnt/docs/importing_data.rst
A    /Users/ogawakiyoshi/lnt/docs/modules/testing.rst
A    /Users/ogawakiyoshi/lnt/lnt/server/ui
A    /Users/ogawakiyoshi/lnt/lnt/server/ui/templates
A    /Users/ogawakiyoshi/lnt/lnt/server/db/migrations/upgrade_7_to_8.py
A    /Users/ogawakiyoshi/lnt/lnt/server/db/search.py
A    /Users/ogawakiyoshi/lnt/lnt/server/reporting/analysis.py
A    /Users/ogawakiyoshi/lnt/lnt/server/db/rules/rule_update_profile_stats.py
A    /Users/ogawakiyoshi/lnt/lnt/server/ui/templates/reporting
A    /Users/ogawakiyoshi/lnt/lnt/server/db/migrations/upgrade_10_to_11.py
A    /Users/ogawakiyoshi/lnt/docs/developer_guide.rst
A    /Users/ogawakiyoshi/lnt/docs/tests.rst
A    /Users/ogawakiyoshi/lnt/lnt/server/db/migrations/README.txt
A    /Users/ogawakiyoshi/lnt/lnt/server/config.py
A    /Users/ogawakiyoshi/lnt/lnt/server/db/migrations/upgrade_12_to_13.py
A    /Users/ogawakiyoshi/lnt/docs/README.txt
A    /Users/ogawakiyoshi/lnt/docs/conf.py
A    /Users/ogawakiyoshi/lnt/docs/report-example.json
A    /Users/ogawakiyoshi/lnt/lnt/server/reporting/__init__.py
A    /Users/ogawakiyoshi/lnt/lnt/server/ui/templates/local.html
A    /Users/ogawakiyoshi/lnt/lnt/server/ui/templates/utils.html
A    /Users/ogawakiyoshi/lnt/lnt/server/db/migrations/upgrade_4_to_5.py
A    /Users/ogawakiyoshi/lnt/lnt/server/db/migrations/upgrade_6_to_7.py
A    /Users/ogawakiyoshi/lnt/docs/Makefile
A    /Users/ogawakiyoshi/lnt/docs/api.rst
A    /Users/ogawakiyoshi/lnt/lnt/server/instance.py
A    /Users/ogawakiyoshi/lnt/lnt/server/ui/templates/error.html
A    /Users/ogawakiyoshi/lnt/lnt/server/ui/templates/reporting/run_report.txt
A    /Users/ogawakiyoshi/lnt/lnt/server/ui/templates/index.html
A    /Users/ogawakiyoshi/lnt/lnt/server/db/migrations/upgrade_9_to_10.py
A    /Users/ogawakiyoshi/lnt/lnt/server/reporting/dailyreport.py
A    /Users/ogawakiyoshi/lnt/docs/concepts.rst
A    /Users/ogawakiyoshi/lnt/lnt/external/__init__.py
A    /Users/ogawakiyoshi/lnt/lnt/server/ui/templates/v4_all_orders.html
A    /Users/ogawakiyoshi/lnt/lnt/server/ui/templates/reporting/runs.html
A    /Users/ogawakiyoshi/lnt/lnt/server/ui/templates/v4_regression_detail.html
A    /Users/ogawakiyoshi/lnt/lnt/server/ui/templates/v4_matrix.html
A    /Users/ogawakiyoshi/lnt/lnt/server/reporting/summaryreport.py
A    /Users/ogawakiyoshi/lnt/lnt/server/ui/templates/submit_run.html
A    /Users/ogawakiyoshi/lnt/lnt/external/stats/pstat.py

(中略)


A    /Users/ogawakiyoshi/lnt/tests/server/db/Inputs/schema-example-nomigration0.yaml
A    /Users/ogawakiyoshi/lnt/tests/runtest/Inputs/test-suite/README.txt
A    /Users/ogawakiyoshi/lnt/tests/runtest/Inputs/rerun-test-suite1/subtest/Makefile
A    /Users/ogawakiyoshi/lnt/tests/server/db/Inputs/lnt_v0.4.0_filled_instance/lnt.cfg
A    /Users/ogawakiyoshi/lnt/tests/server/db/Inputs/schema-example-nomigration1.yaml
A    /Users/ogawakiyoshi/lnt/tests/server/db/Inputs/profile-report.json
A    /Users/ogawakiyoshi/lnt/tests/server/db/Inputs/lnt_v0.4.0_filled_instance/lnt_tmp/default/2012-04/data-2012-04-11_16-47-40o2zWJN.plist
A    /Users/ogawakiyoshi/lnt/tests/runtest/Inputs/rerun-test-suite1/configure
A    /Users/ogawakiyoshi/lnt/tests/server/db/Migrations.py
A    /Users/ogawakiyoshi/lnt/tests/server/ui/change_processing.py
A    /Users/ogawakiyoshi/lnt/tests/server/ui/V4Pages.py
A    /Users/ogawakiyoshi/lnt/tests/SharedInputs/SmallInstance/lnt.wsgi
A    /Users/ogawakiyoshi/lnt/tests/SharedInputs/postgres_wrapper.sh
A    /Users/ogawakiyoshi/lnt/tests/SharedInputs/sample-report.json
A    /Users/ogawakiyoshi/lnt/tests/SharedInputs/FakeCompilers/clang-git-2
A    /Users/ogawakiyoshi/lnt/tests/SharedInputs/FakeCompilers/clang-no-info
A    /Users/ogawakiyoshi/lnt/tests/server/db/Inputs/lnt_v0.4.0_filled_instance/data/lnt.db
A    /Users/ogawakiyoshi/lnt/tests/server/db/CreateV4TestSuiteInstance.py
A    /Users/ogawakiyoshi/lnt/tests/server/reporting/analysis.py
A    /Users/ogawakiyoshi/lnt/tests/server/ui/statsTester.py
A    /Users/ogawakiyoshi/lnt/tests/__init__.py
A    /Users/ogawakiyoshi/lnt/tests/server/ui/Inputs/V4Pages_extra_records.sql
A    /Users/ogawakiyoshi/lnt/tests/server/ui/test_matrix_page.py
A    /Users/ogawakiyoshi/lnt/tests/server/ui/test_api.py
A    /Users/ogawakiyoshi/lnt/tests/SharedInputs/SmallInstance/data/lnt_db_create.sql
A    /Users/ogawakiyoshi/lnt/tests/server/db/search.py
A    /Users/ogawakiyoshi/lnt/tests/server/db/rules.py
A    /Users/ogawakiyoshi/lnt/tests/server/db/Inputs/lnt_v0.4.0_basic_instance/data/lnt.db
A    /Users/ogawakiyoshi/lnt/tests/server/db/Inputs/V4Pages_extra_records.sql
A    /Users/ogawakiyoshi/lnt/tests/server/db/Inputs/schema-example-migratable.yaml
A    /Users/ogawakiyoshi/lnt/tests/server/db/Inputs/lnt_v0.4.0_filled_instance/lnt.wsgi
A    /Users/ogawakiyoshi/lnt/tests/server/db/Inputs/lnt_v0.4.0_filled_instance/lnt_tmp/default/2012-04/data-2012-04-11_16-47-40bEjSGd.plist
A    /Users/ogawakiyoshi/lnt/tests/server/ui/test_api_modify.py
A    /Users/ogawakiyoshi/lnt/tests/server/ui/test_roundtrip.py
A    /Users/ogawakiyoshi/lnt/tests/server/ui/test_api_roundtrip.py
A    /Users/ogawakiyoshi/lnt/tests/SharedInputs/SmallInstance/lnt.cfg
A    /Users/ogawakiyoshi/lnt/tests/SharedInputs/server_wrapper.sh
A    /Users/ogawakiyoshi/lnt/tests/SharedInputs/sample-report1.json
A    /Users/ogawakiyoshi/lnt/tests/SharedInputs/FakeCompilers/clang-git
A    /Users/ogawakiyoshi/lnt/tests/SharedInputs/FakeCompilers/clang++-r154331
A    /Users/ogawakiyoshi/lnt/tests/SharedInputs/sample-report2.json
A    /Users/ogawakiyoshi/lnt/tests/SharedInputs/FakeCompilers/apple-clang-138.1
A    /Users/ogawakiyoshi/lnt/tests/SharedInputs/sample-arm2.json
A    /Users/ogawakiyoshi/lnt/.gitignore
A    /Users/ogawakiyoshi/lnt/tests/server/ui/test_system_info.py
A    /Users/ogawakiyoshi/lnt/tests/SharedInputs/mysql_wrapper.sh
A    /Users/ogawakiyoshi/lnt/tests/SharedInputs/sample-b-small.plist
A    /Users/ogawakiyoshi/lnt/tests/SharedInputs/FakeCompilers/icc-12.1.3
A    /Users/ogawakiyoshi/lnt/tests/SharedInputs/FakeCompilers/clang-r154332
A    /Users/ogawakiyoshi/lnt/tests/SharedInputs/FakeCompilers/README.txt
A    /Users/ogawakiyoshi/lnt/tests/SharedInputs/sample-arm.json
A    /Users/ogawakiyoshi/lnt/requirements.server.txt
A    /Users/ogawakiyoshi/lnt/tests/SharedInputs/sample-a-small.plist
A    /Users/ogawakiyoshi/lnt/tests/SharedInputs/create_temp_instance.py
A    /Users/ogawakiyoshi/lnt/tests/SharedInputs/FakeCompilers/clang-r154331
A    /Users/ogawakiyoshi/lnt/tests/SharedInputs/FakeCompilers/fakecompiler.py
A    /Users/ogawakiyoshi/lnt/tests/SharedInputs/FakeCompilers/clang++-r154332
A    /Users/ogawakiyoshi/lnt/Procfile
A    /Users/ogawakiyoshi/lnt/MANIFEST.in
A    /Users/ogawakiyoshi/lnt/.arcconfig
Checked out revision 313477.

-----
$pyenv virtualenv mysandbox
Fetching package metadata .........
Solving package specifications: .

Package plan for installation in environment /Users/ogawakiyoshi/.pyenv/versions/anaconda3-4.3.0/envs/mysandbox:

The following NEW packages will be INSTALLED:

    certifi:    2016.2.28-py36_0
    openssl:    1.0.2l-0       
    pip:        9.0.1-py36_1   
    python:     3.6.2-0        
    readline:   6.2-2          
    setuptools: 36.4.0-py36_0  
    sqlite:     3.13.0-0       
    tk:         8.5.18-0       
    wheel:      0.29.0-py36_0  
    xz:         5.2.3-0        
    zlib:       1.2.11-0       

openssl-1.0.2l 100% |###########################################| Time: 0:00:00   6.54 MB/s
readline-6.2-2 100% |###########################################| Time: 0:00:00  11.36 MB/s
sqlite-3.13.0- 100% |###########################################| Time: 0:00:00  11.39 MB/s
tk-8.5.18-0.ta 100% |###########################################| Time: 0:00:00  11.62 MB/s
xz-5.2.3-0.tar 100% |###########################################| Time: 0:00:00  10.60 MB/s
zlib-1.2.11-0. 100% |###########################################| Time: 0:00:00  15.07 MB/s
python-3.6.2-0 100% |###########################################| Time: 0:00:01  10.92 MB/s
certifi-2016.2 100% |###########################################| Time: 0:00:00  14.03 MB/s
wheel-0.29.0-p 100% |###########################################| Time: 0:00:00  10.71 MB/s
setuptools-36. 100% |###########################################| Time: 0:00:00   9.10 MB/s
pip-9.0.1-py36 100% |###########################################| Time: 0:00:00  11.58 MB/s
#
# To activate this environment, use:
# > source activate mysandbox
#
# To deactivate this environment, use:
# > source deactivate mysandbox
#

Installing pip from https://bootstrap.pypa.io/get-pip.py...
Requirement already up-to-date: pip in /Users/ogawakiyoshi/.pyenv/versions/anaconda3-4.3.0/envs/mysandbox/lib/python3.6/site-packages
14:09 | 投票する | 投票数(0) | コメント(0)
2017/09/17new

brew install llvm

Tweet ThisSend to Facebook | by kaizen
1 導入
brew install llvm

https://apple.stackexchange.com/questions/227026/how-to-install-recent-clang-with-homebrew

brew install --with-clang llvm



2 入手
mkdir llvm
OgawaKiyoshi-no-MacBook-Pro:~ ogawakiyoshi$ cd llvm
OgawaKiyoshi-no-MacBook-Pro:llvm ogawakiyoshi$ wget http://releases.llvm.org/5.0.0/llvm-5.0.0.src.tar.xz
--2017-09-17 09:45:59-- http://releases.llvm.org/5.0.0/llvm-5.0.0.src.tar.xz
Resolving releases.llvm.org... 151.101.26.49
Connecting to releases.llvm.org|151.101.26.49|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 23411980 (22M) [application/x-tar]
Saving to: 'llvm-5.0.0.src.tar.xz'

llvm-5.0.0.src.tar.xz 100%[==========================>] 22.33M 6.48MB/s in 3.6s

2017-09-17 09:46:04 (6.14 MB/s) - 'llvm-5.0.0.src.tar.xz' saved [23411980/23411980]

OgawaKiyoshi-no-MacBook-Pro:llvm ogawakiyoshi$ wget http://releases.llvm.org/5.0.0/cfe-5.0.0.src.tar.xz
--2017-09-17 09:46:20-- http://releases.llvm.org/5.0.0/cfe-5.0.0.src.tar.xz
Resolving releases.llvm.org... 151.101.26.49
Connecting to releases.llvm.org|151.101.26.49|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 11437024 (11M) [application/x-tar]
Saving to: 'cfe-5.0.0.src.tar.xz'

cfe-5.0.0.src.tar.xz 100%[==========================>] 10.91M 5.30MB/s in 2.1s

2017-09-17 09:46:23 (5.30 MB/s) - 'cfe-5.0.0.src.tar.xz' saved [11437024/11437024]

OgawaKiyoshi-no-MacBook-Pro:llvm ogawakiyoshi$ wget http://releases.llvm.org/5.0.0/compiler-rt-5.0.0.src.tar.xz
--2017-09-17 09:46:39-- http://releases.llvm.org/5.0.0/compiler-rt-5.0.0.src.tar.xz
Resolving releases.llvm.org... 151.101.26.49
Connecting to releases.llvm.org|151.101.26.49|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1507996 (1.4M) [application/x-tar]
Saving to: 'compiler-rt-5.0.0.src.tar.xz'

compiler-rt-5.0.0.src. 100%[==========================>] 1.44M 2.23MB/s in 0.6s

2017-09-17 09:46:41 (2.23 MB/s) - 'compiler-rt-5.0.0.src.tar.xz' saved [1507996/1507996]

OgawaKiyoshi-no-MacBook-Pro:llvm ogawakiyoshi$ brew install cmake
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 1 tap (caskroom/cask).
No changes to formulae.

==> Downloading https://homebrew.bintray.com/bottles/cmake-3.9.2.yosemite.bottle.tar.gz
######################################################################## 100.0%
==> Pouring cmake-3.9.2.yosemite.bottle.tar.gz
==> Caveats
Emacs Lisp files have been installed to:
/usr/local/share/emacs/site-lisp/cmake
==> Summary
???? /usr/local/Cellar/cmake/3.9.2: 2,267 files, 30.3MB

3  解凍
tar Jxfv llvm-5.0.0.src.tar.xz
tar Jxfv cfe-5.0.0.src.tar.xz
tar Jxfv compiler-rt-5.0.0.src.tar.xz

4 cmake
2017年 9月17日 日曜日 09時54分14秒 JST
cmake ../llvm-5.0.0.src/
2017年 9月17日 日曜日 09時54分58秒 JST

make --build .
make: unrecognized option '--build'
Usage: make [options] [target] ...
Options:
-b, -m Ignored for compatibility.
-B, --always-make Unconditionally make all targets.
-C DIRECTORY, --directory=DIRECTORY
Change to DIRECTORY before doing anything.
-d Print lots of debugging information.
--debug[=FLAGS] Print various types of debugging information.
-e, --environment-overrides
Environment variables override makefiles.
--eval=STRING Evaluate STRING as a makefile statement.
-f FILE, --file=FILE, --makefile=FILE
Read FILE as a makefile.
-h, --help Print this message and exit.
-i, --ignore-errors Ignore errors from recipes.
-I DIRECTORY, --include-dir=DIRECTORY
Search DIRECTORY for included makefiles.
-j [N], --jobs[=N] Allow N jobs at once; infinite jobs with no arg.
-k, --keep-going Keep going when some targets can't be made.
-l [N], --load-average[=N], --max-load[=N]
Don't start multiple jobs unless load is below N.
-L, --check-symlink-times Use the latest mtime between symlinks and target.
-n, --just-print, --dry-run, --recon
Don't actually run any recipe; just print them.
-o FILE, --old-file=FILE, --assume-old=FILE
Consider FILE to be very old and don't remake it.
-O[TYPE], --output-sync[=TYPE]
Synchronize output of parallel jobs by TYPE.
-p, --print-data-base Print make's internal database.
-q, --question Run no recipe; exit status says if up to date.
-r, --no-builtin-rules Disable the built-in implicit rules.
-R, --no-builtin-variables Disable the built-in variable settings.
-s, --silent, --quiet Don't echo recipes.
-S, --no-keep-going, --stop
Turns off -k.
-t, --touch Touch targets instead of remaking them.
--trace Print tracing information.
-v, --version Print the version number of make and exit.
-w, --print-directory Print the current directory.
--no-print-directory Turn off -w, even if it was turned on implicitly.
-W FILE, --what-if=FILE, --new-file=FILE, --assume-new=FILE
Consider FILE to be infinitely new.
--warn-undefined-variables Warn when an undefined variable is referenced.

This program built for x86_64-apple-darwin14.1.0
Report bugs to <bug-make@gnu.org>


2017年 9月17日 日曜日 09時59分02秒 JST
cmake --build .
Scanning dependencies of target LLVMDemangle
[ 1%] Building CXX object lib/Demangle/CMakeFiles/LLVMDemangle.dir/ItaniumDemangle.cpp.o
[ 1%] Linking CXX static library ../libLLVMDemangle.a
[ 1%] Built target LLVMDemangle
Scanning dependencies of target LLVMSupport
[ 1%] Building CXX object lib/Support/CMakeFiles/LLVMSupport.dir/AMDGPUCodeObjectMetadata.cpp.o
[ 1%] Building CXX object lib/Support/CMakeFiles/LLVMSupport.dir/APFloat.cpp.o
[ 1%] Building CXX object lib/Support/CMakeFiles/LLVMSupport.dir/APInt.cpp.o
[ 1%] Building CXX object lib/Support/CMakeFiles/LLVMSupport.dir/APSInt.cpp.o
[ 1%] Building CXX object lib/Support/CMakeFiles/LLVMSupport.dir/ARMBuildAttrs.cpp.o
[ 1%] Building CXX object lib/Support/CMakeFiles/LLVMSupport.dir/ARMAttributeParser.cpp.o
[ 1%] Building CXX object lib/Support/CMakeFiles/LLVMSupport.dir/ARMWinEH.cpp.o
[ 1%] Building CXX object lib/Support/CMakeFiles/LLVMSupport.dir/Allocator.cpp.o
[ 1%] Building CXX object lib/Support/CMakeFiles/LLVMSupport.dir/BinaryStreamError.cpp.o
[ 1%] Building CXX object lib/Support/CMakeFiles/LLVMSupport.dir/BinaryStreamReader.cpp.o
[ 1%] Building CXX object lib/Support/CMakeFiles/LLVMSupport.dir/BinaryStreamRef.cpp.o
[ 1%] Building CXX object lib/Support/CMakeFiles/LLVMSupport.dir/BinaryStreamWriter.cpp.o
[ 1%] Building CXX object lib/Support/CMakeFiles/LLVMSupport.dir/BlockFrequency.cpp.o
[ 1%] Building CXX object lib/Support/CMakeFiles/LLVMSupport.dir/BranchProbability.cpp.o
[ 1%] Building CXX object lib/Support/CMakeFiles/LLVMSupport.dir/CachePruning.cpp.o
[ 1%] Building CXX object lib/Support/CMakeFiles/LLVMSupport.dir/circular_raw_ostream.cpp.o

[ 98%] Building CXX object tools/yaml2obj/CMakeFiles/yaml2obj.dir/yaml2wasm.cpp.o
[100%] Linking CXX executable ../../bin/yaml2obj
[100%] Built target yaml2obj
Scanning dependencies of target PipSqueak
[100%] Building CXX object unittests/Support/DynamicLibrary/CMakeFiles/PipSqueak.dir/PipSqueak.cxx.o
[100%] Linking CXX shared library PipSqueak.so
[100%] Built target PipSqueak
Scanning dependencies of target SecondLib
[100%] Building CXX object unittests/Support/DynamicLibrary/CMakeFiles/SecondLib.dir/PipSqueak.cxx.o
[100%] Linking CXX shared library SecondLib.so
[100%] Built target SecondLib
Scanning dependencies of target DynamicLibraryLib
[100%] Building CXX object unittests/Support/DynamicLibrary/CMakeFiles/DynamicLibraryLib.dir/ExportedFuncs.cxx.o
[100%] Linking CXX static library ../../../lib/libDynamicLibraryLib.a
[100%] Built target DynamicLibraryLib
Scanning dependencies of target gtest_main
[100%] Building CXX object utils/unittest/UnitTestMain/CMakeFiles/gtest_main.dir/TestMain.cpp.o
[100%] Linking CXX static library ../../../lib/libgtest_main.a
[100%] Built target gtest_main
2017年 9月17日 日曜日 11時02分03秒 JST

----
 date
2017年 9月17日 日曜日 14時06分44秒 JST
OgawaKiyoshi-no-MacBook-Pro:llvm-build ogawakiyoshi$  cmake --build . --target install
[  1%] Built target LLVMDemangle
[  5%] Built target LLVMSupport
[  6%] Built target LLVMTableGen
[  9%] Built target obj.llvm-tblgen
[  9%] Built target llvm-tblgen
[  9%] Built target AttributeCompatFuncTableGen
[  9%] Built target intrinsics_gen
[ 12%] Built target LLVMCore
[ 12%] Built target LLVMIRReader
[ 19%] Built target LLVMCodeGen
[ 20%] Built target LLVMSelectionDAG
[ 21%] Built target LLVMAsmPrinter
[ 21%] Built target LLVMMIRParser
[ 21%] Built target LLVMGlobalISel
[ 21%] Built target LLVMBinaryFormat
[ 21%] Built target LLVMBitReader
[ 21%] Built target LLVMBitWriter
[ 24%] Built target LLVMTransformUtils
[ 24%] Built target LLVMInstrumentation
[ 26%] Built target LLVMInstCombine
[ 28%] Built target LLVMScalarOpts
[ 30%] Built target LLVMipo
[ 30%] Built target LLVMVectorize
[ 30%] Built target LLVMHello_exports
[ 30%] Built target LLVMHello
[ 30%] Built target LLVMObjCARCOpts
[ 30%] Built target LLVMCoroutines
[ 30%] Built target LLVMLinker
[ 34%] Built target LLVMAnalysis
[ 34%] Built target llvm_vcsrevision_h
[ 35%] Built target LLVMLTO
[ 38%] Built target LLVMMC
[ 38%] Built target LLVMMCParser
[ 38%] Built target LLVMMCDisassembler
d[ 39%] Built target LLVMObject
a[ 39%] Built target LLVMObjectYAML
[ 39%] Built target LLVMOption
[ 41%] Built target LLVMDebugInfoDWARF
[ 41%] Built target LLVMDebugInfoMSF
[ 42%] Built target LLVMDebugInfoCodeView
t[ 45%] Built target LLVMDebugInfoPDB
e[ 45%] Built target LLVMSymbolize
[ 45%] Built target LLVMExecutionEngine
[ 45%] Built target LLVMInterpreter
[ 45%] Built target LLVMMCJIT
[ 46%] Built target LLVMOrcJIT
[ 46%] Built target LLVMRuntimeDyld

[ 46%] Built target LLVMTarget
[ 46%] Built target AArch64CommonTableGen
[ 47%] Built target LLVMAArch64CodeGen
[ 47%] Built target LLVMAArch64Info
[ 47%] Built target LLVMAArch64AsmParser
[ 47%] Built target LLVMAArch64Disassembler
[ 47%] Built target LLVMAArch64AsmPrinter
[ 47%] Built target LLVMAArch64Desc
[ 47%] Built target LLVMAArch64Utils
[ 49%] Built target AMDGPUCommonTableGen
[ 52%] Built target LLVMAMDGPUCodeGen
[ 52%] Built target LLVMAMDGPUUtils
[ 53%] Built target LLVMAMDGPUAsmParser
[ 53%] Built target LLVMAMDGPUAsmPrinter
[ 53%] Built target LLVMAMDGPUDisassembler
[ 53%] Built target LLVMAMDGPUInfo
[ 53%] Built target LLVMAMDGPUDesc
[ 54%] Built target ARMCommonTableGen
[ 56%] Built target LLVMARMCodeGen
[ 56%] Built target LLVMARMInfo
[ 57%] Built target LLVMARMAsmParser
[ 57%] Built target LLVMARMDisassembler
[ 57%] Built target LLVMARMAsmPrinter
[ 57%] Built target LLVMARMDesc
[ 58%] Built target BPFCommonTableGen
[ 58%] Built target LLVMBPFCodeGen
[ 58%] Built target LLVMBPFDisassembler
[ 58%] Built target LLVMBPFAsmPrinter
[ 58%] Built target LLVMBPFInfo
[ 60%] Built target LLVMBPFDesc
[ 61%] Built target HexagonCommonTableGen
[ 64%] Built target LLVMHexagonCodeGen
[ 64%] Built target LLVMHexagonAsmParser
[ 64%] Built target LLVMHexagonInfo
[ 64%] Built target LLVMHexagonDesc
[ 64%] Built target LLVMHexagonDisassembler
[ 64%] Built target LanaiCommonTableGen
[ 64%] Built target LLVMLanaiCodeGen
[ 64%] Built target LLVMLanaiAsmParser
[ 64%] Built target LLVMLanaiInfo
[ 65%] Built target LLVMLanaiDesc
[ 65%] Built target LLVMLanaiAsmPrinter
[ 65%] Built target LLVMLanaiDisassembler
[ 67%] Built target MipsCommonTableGen
[ 68%] Built target LLVMMipsCodeGen
[ 68%] Built target LLVMMipsAsmPrinter
[ 68%] Built target LLVMMipsDisassembler
[ 68%] Built target LLVMMipsInfo
[ 69%] Built target LLVMMipsDesc
[ 69%] Built target LLVMMipsAsmParser
[ 69%] Built target MSP430CommonTableGen
[ 71%] Built target LLVMMSP430CodeGen
[ 71%] Built target LLVMMSP430AsmPrinter
[ 71%] Built target LLVMMSP430Info
[ 71%] Built target LLVMMSP430Desc
[ 72%] Built target NVPTXCommonTableGen
[ 73%] Built target LLVMNVPTXCodeGen
[ 73%] Built target LLVMNVPTXInfo
[ 73%] Built target LLVMNVPTXAsmPrinter
[ 73%] Built target LLVMNVPTXDesc
[ 75%] Built target PowerPCCommonTableGen
[ 76%] Built target LLVMPowerPCCodeGen
[ 76%] Built target LLVMPowerPCAsmParser
[ 76%] Built target LLVMPowerPCDisassembler
[ 76%] Built target LLVMPowerPCAsmPrinter
[ 76%] Built target LLVMPowerPCInfo
[ 76%] Built target LLVMPowerPCDesc
[ 78%] Built target SparcCommonTableGen
[ 78%] Built target LLVMSparcCodeGen
[ 78%] Built target LLVMSparcInfo
[ 79%] Built target LLVMSparcDesc
[ 79%] Built target LLVMSparcAsmPrinter
[ 79%] Built target LLVMSparcAsmParser
[ 79%] Built target LLVMSparcDisassembler
[ 79%] Built target SystemZCommonTableGen
[ 80%] Built target LLVMSystemZCodeGen
[ 80%] Built target LLVMSystemZAsmParser
[ 80%] Built target LLVMSystemZDisassembler
[ 80%] Built target LLVMSystemZAsmPrinter
[ 80%] Built target LLVMSystemZInfo
[ 80%] Built target LLVMSystemZDesc
[ 82%] Built target X86CommonTableGen
[ 83%] Built target LLVMX86CodeGen
[ 83%] Built target LLVMX86AsmParser
[ 83%] Built target LLVMX86Disassembler
[ 83%] Built target LLVMX86AsmPrinter
[ 84%] Built target LLVMX86Desc
[ 84%] Built target LLVMX86Info
[ 84%] Built target LLVMX86Utils
[ 84%] Built target XCoreCommonTableGen
[ 84%] Built target LLVMXCoreCodeGen
[ 84%] Built target LLVMXCoreDisassembler
[ 84%] Built target LLVMXCoreAsmPrinter
[ 84%] Built target LLVMXCoreInfo
[ 86%] Built target LLVMXCoreDesc
[ 86%] Built target LLVMAsmParser
[ 86%] Built target LLVMLineEditor
[ 87%] Built target LLVMProfileData
[ 87%] Built target LLVMCoverage
[ 89%] Built target LLVMFuzzerNoMainObjects
[ 89%] Built target LLVMFuzzerNoMain
[ 89%] Built target LLVMFuzzer
[ 89%] Built target LLVMPasses
[ 89%] Built target DllOptionsTableGen
[ 89%] Built target LLVMDlltoolDriver
[ 90%] Built target LibOptionsTableGen
[ 90%] Built target LLVMLibDriver
[ 90%] Built target LLVMXRay
[ 90%] Built target gtest
[ 90%] Built target LLVMTestingSupport
[ 90%] Built target FileCheck
[ 90%] Built target llvm-PerfectShuffle
[ 90%] Built target count
[ 90%] Built target not
[ 90%] Built target yaml-bench
[ 90%] Built target LTO_exports
[ 90%] Built target LTO
[ 90%] Built target llvm-ar
[ 90%] Built target llvm-lib
[ 90%] Built target llvm-dlltool
[ 90%] Built target llvm-ranlib
[ 90%] Built target llvm-config
[ 90%] Built target llvm-lto
[ 90%] Built target llvm-profdata
[ 90%] Built target bugpoint
[ 90%] Built target BugpointPasses_exports
[ 90%] Built target BugpointPasses
[ 90%] Built target llvm-dsymutil
[ 90%] Built target llc
[ 90%] Built target lli
[ 90%] Built target lli-child-target
[ 90%] Built target llvm-as
[ 91%] Built target llvm-bcanalyzer
[ 91%] Built target llvm-c-test
[ 91%] Built target llvm-cat
[ 91%] Built target llvm-cov
[ 93%] Built target CvtResTableGen
[ 94%] Built target llvm-cvtres
[ 94%] Built target llvm-cxxdump
[ 94%] Built target llvm-cxxfilt
[ 94%] Built target llvm-diff
[ 94%] Built target llvm-dis
[ 94%] Built target llvm-dwarfdump
[ 94%] Built target llvm-dwp
[ 94%] Built target llvm-extract
[ 95%] Built target llvm-link
[ 95%] Built target llvm-lto2
[ 95%] Built target llvm-mc
[ 95%] Built target llvm-mcmarkup
[ 95%] Built target llvm-modextract
[ 95%] Built target MtTableGen
[ 95%] Built target llvm-mt
[ 95%] Built target llvm-nm
[ 95%] Built target llvm-objdump
[ 95%] Built target llvm-opt-report
[ 97%] Built target llvm-pdbutil
[ 98%] Built target llvm-readobj
[ 98%] Built target llvm-readelf
[ 98%] Built target llvm-rtdyld
[ 98%] Built target llvm-size
[ 98%] Built target llvm-split
[ 98%] Built target llvm-stress
[ 98%] Built target llvm-strings
[ 98%] Built target llvm-symbolizer
[ 98%] Built target llvm-xray
[ 98%] Built target obj2yaml
[ 98%] Built target opt
[ 98%] Built target sancov
[ 98%] Built target sanstats
[ 98%] Built target verify-uselistorder
[100%] Built target yaml2obj
[100%] Built target PipSqueak
[100%] Built target SecondLib
[100%] Built target DynamicLibraryLib
[100%] Built target gtest_main
Install the project...
-- Install configuration: "Debug"
-- Installing: /usr/local/include/llvm
-- Installing: /usr/local/include/llvm/ADT
-- Installing: /usr/local/include/llvm/ADT/AllocatorList.h
-- Installing: /usr/local/include/llvm/ADT/APFloat.

-- Installing: /usr/local/lib/cmake/llvm/./FindOCaml.cmake
-- Installing: /usr/local/lib/cmake/llvm/./FindSphinx.cmake
-- Installing: /usr/local/lib/cmake/llvm/./GenerateVersionFromCVS.cmake
-- Installing: /usr/local/lib/cmake/llvm/./GetSVN.cmake
-- Installing: /usr/local/lib/cmake/llvm/./HandleLLVMOptions.cmake
-- Installing: /usr/local/lib/cmake/llvm/./HandleLLVMStdlib.cmake
-- Installing: /usr/local/lib/cmake/llvm/./LLVMExternalProjectUtils.cmake
-- Installing: /usr/local/lib/cmake/llvm/./LLVMInstallSymlink.cmake
-- Installing: /usr/local/lib/cmake/llvm/./LLVMProcessSources.cmake
-- Installing: /usr/local/lib/cmake/llvm/./TableGen.cmake
-- Installing: /usr/local/lib/cmake/llvm/./VersionFromVCS.cmake
OgawaKiyoshi-no-MacBook-Pro:llvm-build ogawakiyoshi$ date
2017年 9月17日 日曜日 14時08分15秒 JST

date
2017年 9月17日 日曜日 14時11分04秒 JST
OgawaKiyoshi-no-MacBook-Pro:llvm-build ogawakiyoshi$ make check-all
[  0%] Built target gtest_main
[  1%] Built target LLVMDemangle
[  5%] Built target LLVMSupport
[  7%] Built target obj.llvm-tblgen
[  8%] Built target LLVMTableGen
[  8%] Built target llvm-tblgen
[  8%] Built target intrinsics_gen
[  8%] Built target gtest
Scanning dependencies of target XRayTests
[  8%] Building CXX object unittests/XRay/CMakeFiles/XRayTests.dir/GraphTest.cpp.o
[  8%] Linking CXX executable XRayTests
[  8%] Built target XRayTests
Scanning dependencies of target ADTTests
[  8%] Building CXX object unittests/ADT/CMakeFiles/ADTTests.dir/APFloatTest.cpp.o
[  8%] Building CXX object unittests/ADT/CMakeFiles/ADTTests.dir/APIntTest.cpp.o
[  8%] Building CXX object unittests/ADT/CMakeFiles/ADTTests.dir/APSIntTest.cpp.o
[  8%] Building CXX object unittests/ADT/CMakeFiles/ADTTests.dir/ArrayRefTest.cpp.o
[  8%] Building CXX object unittests/ADT/CMakeFiles/ADTTests.dir/BitmaskEnumTest.cpp.o
[  8%] Building CXX object unittests/ADT/CMakeFiles/ADTTests.dir/BitVectorTest.cpp.o
[  8%] Building CXX object unittests/ADT/CMakeFiles/ADTTests.dir/BreadthFirstIteratorTest.cpp.o

[ 98%] Built target llvm-cxxdump
[ 98%] Built target llvm-cxxfilt
[ 98%] Built target llvm-diff
[ 98%] Built target llvm-dis
[ 98%] Built target llvm-dwarfdump
[ 98%] Built target llvm-dwp
[ 98%] Built target llvm-extract
[100%] Built target llvm-link
[100%] Built target llvm-lto2
Scanning dependencies of target check-all
[100%] Running all regression tests
Testing Time: 2076.17s
  Expected Passes    : 20893
  Expected Failures  : 140
  Unsupported Tests  : 438
[100%] Built target check-all
OgawaKiyoshi-no-MacBook-Pro:llvm-build ogawakiyoshi$ date
2017年 9月17日 日曜日 14時52分37秒 JST
09:41 | 投票する | 投票数(0) | コメント(0)
2017/09/17

cppcheck

Tweet ThisSend to Facebook | by kaizen
brew install cppcheck
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 2 taps (caskroom/cask, homebrew/core).
==> Updated Formulae
bandcamp-dl         heroku              khal                node-build
firebase-cli        ipython             liblockfile         pc6001vx
grpc                ipython@5           libmowgli           saldl
Warning: Calling BottleSpecification.revision is deprecated!
Use BottleSpecification.rebuild instead.
/usr/local/Homebrew/Library/Taps/pizzafactory/homebrew-toppers_open/toppers-ngk-cfg109.rb:11:in `block in <class:ToppersNgkCfg109>'
Please report this to the pizzafactory/toppers_open tap!

Error: Calling BottleSpecification#sha1 is disabled!
Use BottleSpecification#sha256 instead.
/usr/local/Homebrew/Library/Taps/pizzafactory/homebrew-toppers_open/toppers-ngk-cfg109.rb:12:in `block in <class:ToppersNgkCfg109>'
Please report this to the pizzafactory/toppers_open tap!
If reporting this issue please do so at (not Homebrew/brew or Homebrew/core):
  https://github.com/pizzafactory/homebrew-toppers_open/issues
==> Downloading https://homebrew.bintray.com/bottles/cppcheck-1.80.yosemite.bott
######################################################################## 100.0%
==> Pouring cppcheck-1.80.yosemite.bottle.1.tar.gz
  /usr/local/Cellar/cppcheck/1.80: 27 files, 3.2MB

$ cppcheck DCL50.cpp
Checking DCL50.cpp ...

cppcheck --help
Cppcheck - A tool for static C/C++ code analysis

Syntax:
    cppcheck [OPTIONS] [files or paths]

If a directory is given instead of a filename, *.cpp, *.cxx, *.cc, *.c++, *.c,
*.tpp, and *.txx files are checked recursively from the given directory.

Options:
    --cppcheck-build-dir=<dir>
                         Analysis output directory. Useful for various data.
                         Some possible usages are; whole program analysis,
                         incremental analysis, distributed analysis.
    --check-config       Check cppcheck configuration. The normal code
                         analysis is disabled by this flag.
    --check-library      Show information messages when library files have
                         incomplete info.
    --config-exclude=<dir>
                         Path (prefix) to be excluded from configuration
                         checking. Preprocessor configurations defined in
                         headers (but not sources) matching the prefix will not
                         be considered for evaluation.
    --config-excludes-file=<file>
                         A file that contains a list of config-excludes
    --dump               Dump xml data for each translation unit. The dump
                         files have the extension .dump and contain ast,
                         tokenlist, symboldatabase, valueflow.
    -D<ID>               Define preprocessor symbol. Unless --max-configs or
                         --force is used, Cppcheck will only check the given
                         configuration when -D is used.
                         Example: '-DDEBUG=1 -D__cplusplus'.
    -U<ID>               Undefine preprocessor symbol. Use -U to explicitly
                         hide certain #ifdef <ID> code paths from checking.
                         Example: '-UDEBUG'
    -E                   Print preprocessor output on stdout and don't do any
                         further processing.
    --enable=<id>        Enable additional checks. The available ids are:
                          * all
                                  Enable all checks. It is recommended to only
                                  use --enable=all when the whole program is
                                  scanned, because this enables unusedFunction.
                          * warning
                                  Enable warning messages
                          * style
                                  Enable all coding style checks. All messages
                                  with the severities 'style', 'performance' and
                                  'portability' are enabled.
                          * performance
                                  Enable performance messages
                          * portability
                                  Enable portability messages
                          * information
                                  Enable information messages
                          * unusedFunction
                                  Check for unused functions. It is recommend
                                  to only enable this when the whole program is
                                  scanned.
                          * missingInclude
                                  Warn if there are missing includes. For
                                  detailed information, use '--check-config'.
                         Several ids can be given if you separate them with
                         commas. See also --std
    --error-exitcode=<n> If errors are found, integer [n] is returned instead of
                         the default '0'. '1' is returned
                         if arguments are not valid or if no input files are
                         provided. Note that your operating system can modify
                         this value, e.g. '256' can become '0'.
    --errorlist          Print a list of all the error messages in XML format.
    --doc                Print a list of all available checks.
    --exitcode-suppressions=<file>
                         Used when certain messages should be displayed but
                         should not cause a non-zero exitcode.
    --file-list=<file>   Specify the files to check in a text file. Add one
                         filename per line. When file is '-,' the file list will
                         be read from standard input.
    -f, --force          Force checking of all configurations in files. If used
                         together with '--max-configs=', the last option is the
                         one that is effective.
    -h, --help           Print this help.
    -I <dir>             Give path to search for include files. Give several -I
                         parameters to give several paths. First given path is
                         searched for contained header files first. If paths are
                         relative to source files, this is not needed.
    --includes-file=<file>
                         Specify directory paths to search for included header
                         files in a text file. Add one include path per line.
                         First given path is searched for contained header
                         files first. If paths are relative to source files,
                         this is not needed.
    --include=<file>
                         Force inclusion of a file before the checked file. Can
                         be used for example when checking the Linux kernel,
                         where autoconf.h needs to be included for every file
                         compiled. Works the same way as the GCC -include
                         option.
    -i <dir or file>     Give a source file or source file directory to exclude
                         from the check. This applies only to source files so
                         header files included by source files are not matched.
                         Directory name is matched to all parts of the path.
    --inconclusive       Allow that Cppcheck reports even though the analysis is
                         inconclusive.
                         There are false positives with this option. Each result
                         must be carefully investigated before you know if it is
                         good or bad.
    --inline-suppr       Enable inline suppressions. Use them by placing one or
                         more comments, like: '// cppcheck-suppress warningId'
                         on the lines before the warning to suppress.
    -j <jobs>            Start <jobs> threads to do the checking simultaneously.
    -l <load>            Specifies that no new threads should be started if
                         there are other threads running and the load average is
                         at least <load>.
    --language=<language>, -x <language>
                         Forces cppcheck to check all files as the given
                         language. Valid values are: c, c++
    --library=<cfg>      Load file <cfg> that contains information about types
                         and functions. With such information Cppcheck
                         understands your code better and therefore you
                         get better results. The std.cfg file that is
                         distributed with Cppcheck is loaded automatically.
                         For more information about library files, read the
                         manual.
    --output-file=<file> Write results to file, rather than standard error.
    --project=<file>     Run Cppcheck on project. The <file> can be a Visual
                         Studio Solution (*.sln), Visual Studio Project
                         (*.vcxproj), or compile database
                         (compile_commands.json). The files to analyse,
                         include paths, defines, platform and undefines in
                         the specified file will be used.
    --max-configs=<limit>
                         Maximum number of configurations to check in a file
                         before skipping it. Default is '12'. If used together
                         with '--force', the last option is the one that is
                         effective.
    --platform=<type>, --platform=<file>
                         Specifies platform specific types and sizes. The
                         available builtin platforms are:
                          * unix32
                                 32 bit unix variant
                          * unix64
                                 64 bit unix variant
                          * win32A
                                 32 bit Windows ASCII character encoding
                          * win32W
                                 32 bit Windows UNICODE character encoding
                          * win64
                                 64 bit Windows
                          * avr8
                                 8 bit AVR microcontrollers
                          * native
                                 Type sizes of host system are assumed, but no
                                 further assumptions.
                          * unspecified
                                 Unknown type sizes
    --plist-output=<path>
                         Generate Clang-plist output files in folder.
    -q, --quiet          Do not show progress reports.
    -rp, --relative-paths
    -rp=<paths>, --relative-paths=<paths>
                         Use relative paths in output. When given, <paths> are
                         used as base. You can separate multiple paths by ';'.
                         Otherwise path where source files are searched is used.
                         We use string comparison to create relative paths, so
                         using e.g. ~ for home folder does not work. It is
                         currently only possible to apply the base paths to
                         files that are on a lower level in the directory tree.
    --report-progress    Report progress messages while checking a file.
    --rule=<rule>        Match regular expression.
    --rule-file=<file>   Use given rule file. For more information, see:
                         http://sourceforge.net/projects/cppcheck/files/Articles/
    --std=<id>           Set standard.
                         The available options are:
                          * posix
                                 POSIX compatible code
                          * c89
                                 C code is C89 compatible
                          * c99
                                 C code is C99 compatible
                          * c11
                                 C code is C11 compatible (default)
                          * c++03
                                 C++ code is C++03 compatible
                          * c++11
                                 C++ code is C++11 compatible (default)
                         More than one --std can be used:
                           'cppcheck --std=c99 --std=posix file.c'
    --suppress=<spec>    Suppress warnings that match <spec>. The format of
                         <spec> is:
                         [error id]:[filename]:[line]
                         The [filename] and [line] are optional. If [error id]
                         is a wildcard '*', all error ids match.
    --suppressions-list=<file>
                         Suppress warnings listed in the file. Each suppression
                         is in the same format as <spec> above.
    --template='<text>'  Format the error messages. E.g.
                         '{file}:{line},{severity},{id},{message}' or
                         '{file}({line}):({severity}) {message}' or
                         '{callstack} {message}'
                         Pre-defined templates: gcc, vs, edit.
    -v, --verbose        Output more detailed error information.
    --version            Print out version number.
    --xml                Write results in xml format to error stream (stderr).
    --xml-version=<version>
                         Select the XML file version. Currently versions 1 and
                         2 are available. The default version is 1.
Example usage:
  # Recursively check the current folder. Print the progress on the screen and
  # write errors to a file:
  cppcheck . 2> err.txt

  # Recursively check ../myproject/ and don't print progress:
  cppcheck --quiet ../myproject/

  # Check test.cpp, enable all checks:
  cppcheck --enable=all --inconclusive --std=posix test.cpp

  # Check f.cpp and search include files from inc1/ and inc2/:
  cppcheck -I inc1/ -I inc2/ f.cpp

For more information:
    http://cppcheck.net/manual.pdf

------
 cppcheck --enable=all --inconclusive --std=posix DCL50.cpp
Checking DCL50.cpp ...
(information) Cppcheck cannot find all the include files (use --check-config for details)

---
$ cppcheck --enable=all --inconclusive --std=posix DCL50.cpp --check-config
Checking DCL50.cpp ...
[DCL50.cpp:11]: (information) Include file: <iostream> not found. Please note: Cppcheck does not need standard library headers to get proper results.
[DCL50.cpp:12]: (information) Include file: <string> not found. Please note: Cppcheck does not need standard library headers to get proper results.
[DCL50.cpp:13]: (information) Include file: <cstdarg> not found. Please note: Cppcheck does not need standard library headers to get proper results.
$ printenv
INCLUDE=-I/usr/local/opt/llvm/include:/opt/X11/include

---
cppcheck --enable=all  --check-config -I /usr/local/opt/llvm/include/c++/v1 DCL50.cpp
Checking DCL50.cpp ...
[/usr/local/opt/llvm/include/c++/v1/__config:246]: (information) Include file: <winapifamily.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
[/usr/local/opt/llvm/include/c++/v1/cassert:21]: (information) Include file: <assert.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
[/usr/local/opt/llvm/include/c++/v1/ctime:48]: (information) Include file: <time.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
[/usr/local/opt/llvm/include/c++/v1/__threading_support:30]: (information) Include file: <windows.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
[/usr/local/opt/llvm/include/c++/v1/__threading_support:31]: (information) Include file: <process.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
[/usr/local/opt/llvm/include/c++/v1/__threading_support:32]: (information) Include file: <fibersapi.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
[/usr/local/opt/llvm/include/c++/v1/support/win32/locale_win32.h:16]: (information) Include file: <xlocinfo.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
[/usr/local/opt/llvm/include/c++/v1/cstdarg:36]: (information) Include file: <stdarg.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
[/usr/local/opt/llvm/include/c++/v1/__bsd_locale_fallbacks.h:18]: (information) Include file: <stdarg.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
[/usr/local/opt/llvm/include/c++/v1/__config:284]: (information) Include file: <endian.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
08:40 | 投票する | 投票数(0) | コメント(0)
12345