1

私が見たすべてのソフトウェアは、ファイルの先頭に著作権ステートメントを含み、かなりの数行のコメントを取ります。したがって、コードを表示するには下にスクロールする必要があります。これは、特にコード自体が非常に短い場合は、少し面倒です。

ファイルの下部に著作権ステートメントを保持し、すべての句を1行(または数行)に結合する方がよいと思います。これは、正式な問題を解決するためだけのものです。読みやすいバージョンは、LICENSEファイルで入手できます。

しかし、私は今のところそのような練習を見たことがありません。それは単なる部族の習慣ですか、それともその理由がありますか?

編集:例としてGNUSTLライブラリの<list>を次に示します。

// <list> -*- C++ -*-

// Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library.  This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 2, or (at your option)
// any later version.

// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING.  If not, write to the Free
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.

// As a special exception, you may use this file as part of a free software
// library without restriction.  Specifically, if other files instantiate
// templates or use macros or inline functions from this file, or you compile
// this file and link it with other files to produce an executable, this
// file does not by itself cause the resulting executable to be covered by
// the GNU General Public License.  This exception does not however
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.

/*
 *
 * Copyright (c) 1994
 * Hewlett-Packard Company
 *
 * Permission to use, copy, modify, distribute and sell this software
 * and its documentation for any purpose is hereby granted without fee,
 * provided that the above copyright notice appear in all copies and
 * that both that copyright notice and this permission notice appear
 * in supporting documentation.  Hewlett-Packard Company makes no
 * representations about the suitability of this software for any
 * purpose.  It is provided "as is" without express or implied warranty.
 *
 *
 * Copyright (c) 1996,1997
 * Silicon Graphics Computer Systems, Inc.
 *
 * Permission to use, copy, modify, distribute and sell this software
 * and its documentation for any purpose is hereby granted without fee,
 * provided that the above copyright notice appear in all copies and
 * that both that copyright notice and this permission notice appear
 * in supporting documentation.  Silicon Graphics makes no
 * representations about the suitability of this software for any
 * purpose.  It is provided "as is" without express or implied warranty.
 */

/** @file list
 *  This is a Standard C++ Library header.  You should @c #include this header
 *  in your programs, rather than any of the "st[dl]_*.h" implementation files.
 */

#ifndef _GLIBCXX_LIST
#define _GLIBCXX_LIST 1

#pragma GCC system_header

#include <bits/functexcept.h>
#include <bits/stl_algobase.h>
#include <bits/allocator.h>
#include <bits/stl_construct.h>
#include <bits/stl_uninitialized.h>
#include <bits/stl_list.h>

#ifndef _GLIBCXX_EXPORT_TEMPLATE
# include <bits/list.tcc>
#endif

#ifdef _GLIBCXX_DEBUG
# include <debug/list>
#endif

#endif /* _GLIBCXX_LIST */
4

2 に答える 2

1

必ずしもカスタムや要件である必要はありませんが、標準では、コメントはコード定義の前に進む必要があると規定されている傾向があります。例としてNDOC表記を見てください。

著作権の場合、通常、コードの使用を続行する前にユーザーに読んでもらいます(EULAは常にインストーラーの先頭に表示されます)。コード定義の下部に著作権表示を配置すると、見落とされる可能性が高くなります。

于 2010-08-21T01:30:19.217 に答える
0

ファイルの先頭に著作権コメントを付けると、誰かがファイルを開いたときに著作権表示が表示されます(ファイルを開いた人が、最後にアクセスした行に自動的に移動するエディターを使用しない場合)。著作権コメントがファイルの下部に配置される場合、人々は著作権を表示するために最後までスクロールする必要があります。これは、誰かが最初に見たいと思うものです。

于 2010-08-21T01:35:23.477 に答える