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

✨️ gcc(C言語)・g++(C++) #197

Merged
merged 5 commits into from
Jan 28, 2025
Merged
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
6 changes: 6 additions & 0 deletions exec-container/compilers/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
haxe = import ./haxe {inherit pkgs;};
raku = import ./raku {pkgs = allpkgs.release2411;};
java = import ./java {pkgs = allpkgs.release2411;};
gcc = import ./gcc {pkgs = allpkgs.release2411;};
gxx = import ./g++ {pkgs = allpkgs.release2411;};
in {
all = [
golang
Expand All @@ -20,6 +22,8 @@ in {
haxe
raku
java
gcc
gxx
];
traojudge =
[
Expand All @@ -33,4 +37,6 @@ in {
#raku.traojudge
]
++ java.traojudge.languages;
#++ gcc.traojudge.languages;
#++ gxx.traojudge.languages;
}
13 changes: 13 additions & 0 deletions exec-container/compilers/g++/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{pkgs}: let
myGcc = pkgs.gcc;
myBoost = pkgs.boost;
myGmp = pkgs.gmp;
myEigen = pkgs.eigen;
myAcLibrary = pkgs.ac-library;
in
pkgs.writeShellScriptBin "g++" ''
export LD_LIBRARY_PATH="${myBoost}/lib:${myGmp}/lib:${myEigen}/share:$LD_LIBRARY_PATH"
export LIBRARY_PATH="${myBoost}/lib:${myGmp}/lib:${myEigen}/share:$LIBRARY_PATH"
export CPLUS_INCLUDE_PATH="${myBoost.dev}/include:${myGmp.dev}/include:${myEigen}/include:${myAcLibrary.dev}/include:$CPLUS_INCLUDE_PATH"
exec "${myGcc}/bin/g++" "$@" -lgmpxx -lgmp
''
49 changes: 49 additions & 0 deletions exec-container/compilers/g++/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#include <iostream>
#include <boost/multiprecision/cpp_int.hpp>
#include <gmpxx.h>
#include <eigen3/Eigen/Dense>
#include <atcoder/modint>

using namespace std;
using namespace boost::multiprecision;
using namespace Eigen;
using namespace atcoder;

int main(void)
{
cout << "Hello, World!" << endl;

// Boostテスト
cpp_int a = 1;
for (int i = 1; i <= 100; i++)
{
a += i;
}
cout << a << endl;

// GMPテスト
mpz_class b = 1;
for (int i = 1; i <= 100; i++)
{
b += i;
}
cout << b << endl;

// Eigenテスト
MatrixXd m(2, 2);
m(0, 0) = 3;
m(1, 0) = 2.5;
m(0, 1) = -1;
m(1, 1) = m(1, 0) + m(0, 1);
cout << m << endl;

// ac-libraryテスト
modint1000000007 c = 1;
for (int i = 1; i <= 100; i++)
{
c += i;
}
cout << c.val() << endl;

return 0;
}
4 changes: 4 additions & 0 deletions exec-container/compilers/gcc/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{pkgs}: let
myGcc = pkgs.gcc;
in
pkgs.writeShellScriptBin "gcc" "exec ${myGcc}/bin/gcc $@"
7 changes: 7 additions & 0 deletions exec-container/compilers/gcc/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#include <stdio.h>

int main(void)
{
printf("Hello, World!\n");
return 0;
}
Loading