Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Formatting and makefile step for clang++ -Weverything with necessary fixes. #19

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# C and C++
---
AlignEscapedNewlines: Left
AlignTrailingComments: true
BasedOnStyle: LLVM
BraceWrapping:
AfterCaseLabel: false
AfterClass: false
AfterControlStatement: Never
AfterFunction: false
AfterEnum: false
AfterNamespace: false
AfterStruct: false
AfterUnion: false
AfterExternBlock: false
BeforeCatch: false
BeforeElse: false
BeforeLambdaBody: false
BreakBeforeBraces: Custom
BreakBeforeInheritanceComma: true
BreakConstructorInitializers: BeforeComma
ColumnLimit: 120
IndentAccessModifiers: false
IndentCaseLabels: true
IndentPPDirectives: None
IndentRequiresClause: false
IndentWidth: 2
InsertNewlineAtEOF: true
# clang clang-format 19
# KeepEmptyLines:
# AtEndOfFile: true
LineEnding: LF
NamespaceIndentation: None
QualifierAlignment: Right
ReflowComments: false
RemoveSemicolon: true
RequiresClausePosition: WithFollowing
RequiresExpressionIndentation: OuterScope
SpaceAfterTemplateKeyword: false
TabWidth: 2
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/.vscode/
/demo_sha1
/test_clang1
/test_sha1
18 changes: 12 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
CROSS =
CXX = $(CROSS)g++
RM = rm -f
CROSS =
CXX = $(CROSS)g++
RM = rm -f
CXX_CLANG = clang++
CXX_EXTRA_FLAGS = -Werror -Weverything -Wno-c++98-compat-pedantic -Wno-unsafe-buffer-usage -Wno-switch-default

all: demo_sha1 test_sha1

demo_sha1: demo_sha1.cpp sha1.cpp sha1.hpp
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -Wall -Wextra -std=c++11 -o $@ demo_sha1.cpp sha1.cpp
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -Wall -Wextra -std=c++11 -Wconversion -o $@ demo_sha1.cpp sha1.cpp

test_sha1: test_sha1.cpp test_sha1_file.cpp sha1.hpp
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -Wall -Wextra -std=c++11 -o $@ test_sha1.cpp test_sha1_file.cpp sha1.cpp
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -Wall -Wextra -std=c++11 -Wconversion -o $@ test_sha1.cpp test_sha1_file.cpp sha1.cpp

test_clang1: test_sha1.cpp test_sha1_file.cpp sha1.hpp
$(CXX_CLANG) $(CXX_EXTRA_FLAGS) -o $@ test_sha1.cpp test_sha1_file.cpp sha1.cpp


check: test_sha1
./test_sha1

clean:
$(RM) demo_sha1 test_sha1
$(RM) demo_sha1 test_sha1 test_clang
25 changes: 12 additions & 13 deletions demo_sha1.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/*
demo_sha1.cpp - demo program of

============
SHA-1 in C++
============

100% Public Domain.

Original C Code
-- Steve Reid <steve@edmweb.com>
Small changes to fit into bglibs
Expand All @@ -16,21 +16,20 @@
*/

#include "sha1.hpp"
#include <string>
#include <iostream>
using std::string;
#include <string>
using std::cout;
using std::endl;
using std::string;

int main(int /* argc */, const char ** /* argv */)
{
const string input = "abc";
int main(int /* argc */, char const ** /* argv */) {
string const input = "abc";

SHA1 checksum;
checksum.update(input);
const string hash = checksum.final();
SHA1 checksum;
checksum.update(input);
string const hash = checksum.final();

cout << "The SHA-1 of \"" << input << "\" is: " << hash << endl;
cout << "The SHA-1 of \"" << input << "\" is: " << hash << endl;

return 0;
return 0;
}
2 changes: 1 addition & 1 deletion sha1.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
sha1.cpp - This file is intenionally left blank.
sha1.cpp - This file is intentionally left blank.
This file is no longer needed. It is only kept for backard compatibility.
Simply: #include "sha1.hpp"
*/
Loading