PyCUDA Programming:extern “C”の重要性

その買うを、もっとハッピーに。|ハピタス

extern “C”とno_extern_c=Trueの必要性を示すために、このサイトに載っている下記のコードを試してみた。

import pycuda.autoinit, pycuda.driver
from pycuda.compiler import SourceModule
import numpy
import time

mod = SourceModule('''
#include <thrust/random.h>
extern "C" {
__global__ void test_rand(int numRand, float *samples)
{
  int threadID = blockIdx.x * gridDim.x + threadIdx.x;
  thrust::default_random_engine rng;
  rng.discard(numRand * threadID);
  
  thrust::uniform_real_distribution<float> rand01(0,1);

  float acc=0.0;

  for (int i=0; i < numRand; i++) {
	float r = rand01(rng);
	acc += r;
  }
  samples[threadID] = acc/numRand;  // Normalize back to range [0,1)
}
}
''', no_extern_c=True, include_dirs=[''])

test_rand = mod.get_function('test_rand')
### Compute many sums of random numbers
numRand = 512
threads_per_block = 256
blocks = 512

threads = threads_per_block * blocks
print ('Sampling sum of', numRand, 'random numbers', threads, 'times.')
samples = numpy.zeros(threads, dtype=numpy.float32)

start = time.time()
test_rand(numpy.int32(numRand), pycuda.driver.Out(samples), grid=(blocks,1), block=(threads_per_block,1,1))
stop = time.time()
print ('Execution+copy time = %1.1f msec' % ( (stop-start) * 1000.0,))

### Look at results in a lame text-only way
### Squint hard!  Central Limit Theorem says this is approximately a Gaussian.
hist, bin_edges = numpy.histogram(samples, bins=126, range=(0.3, 0.7))
print ('Distribution:', hist)
Sampling sum of 512 random numbers 131072 times.
Execution+copy time = 2.0 msec
Distribution: [   0    0    0    0    0    0    0    0    0    0    0    0    0    0
    0    0    0    0    0    0    0    0    0    0    0    0    0    0
    0    0    0    0    0    0    0    0    0    0    0    0    0    0
    0    0    0    1    1    3    8   19   58  120  217  399  636 1126
 1806 2579 3541 4465 5456 6037 6425 6366 6027 5395 4425 3525 2502 1714
 1162  699  397  213  127   60   14    6    6    1    0    0    0    0
    0    0    0    0    0    0    0    0    0    0    0    0    0    0
    0    0    0    0    0    0    0    0    0    0    0    0    0    0
    0    0    0    0    0    0    0    0    0    0    0    0    0    0]

上のコードで使われているextern Cがないと、下の例で示すようにコンパイルエラーになり、さらにno_extern_c=Trueがないとエラーになる。

import pycuda.autoinit, pycuda.driver
from pycuda.compiler import SourceModule
import numpy
import time

mod = SourceModule('''
#include <thrust/random.h>
{
__global__ void test_rand(int numRand, float *samples)
{
  int threadID = blockIdx.x * gridDim.x + threadIdx.x;
  thrust::default_random_engine rng;
  rng.discard(numRand * threadID);
  
  thrust::uniform_real_distribution<float> rand01(0,1);

  float acc=0.0;

  for (int i=0; i < numRand; i++) {
	float r = rand01(rng);
	acc += r;
  }
  samples[threadID] = acc/numRand;  // Normalize back to range [0,1)
}
}
''', include_dirs=[''])

test_rand = mod.get_function('test_rand')
### Compute many sums of random numbers
numRand = 512
threads_per_block = 256
blocks = 512

threads = threads_per_block * blocks
print ('Sampling sum of', numRand, 'random numbers', threads, 'times.')
samples = numpy.zeros(threads, dtype=numpy.float32)

start = time.time()
test_rand(numpy.int32(numRand), pycuda.driver.Out(samples), grid=(blocks,1), block=(threads_per_block,1,1))
stop = time.time()
print ('Execution+copy time = %1.1f msec' % ( (stop-start) * 1000.0,))

### Look at results in a lame text-only way
### Squint hard!  Central Limit Theorem says this is approximately a Gaussian.
hist, bin_edges = numpy.histogram(samples, bins=126, range=(0.3, 0.7))
print ('Distribution:', hist)
---------------------------------------------------------------------------
CompileError                              Traceback (most recent call last)
<ipython-input-17-c3569e4a54de> in <module>
     24 }
     25 }
---> 26 ''', include_dirs=[''])
     27 
     28 test_rand = mod.get_function('test_rand')

~/.pyenv/versions/3.6.6/envs/py36/lib/python3.6/site-packages/pycuda/compiler.py in __init__(self, source, nvcc, options, keep, no_extern_c, arch, code, cache_dir, include_dirs)
    289 
    290         cubin = compile(source, nvcc, options, keep, no_extern_c,
--> 291                 arch, code, cache_dir, include_dirs)
    292 
    293         from pycuda.driver import module_from_buffer

~/.pyenv/versions/3.6.6/envs/py36/lib/python3.6/site-packages/pycuda/compiler.py in compile(source, nvcc, options, keep, no_extern_c, arch, code, cache_dir, include_dirs, target)
    252         options.append("-I"+i)
    253 
--> 254     return compile_plain(source, options, keep, nvcc, cache_dir, target)
    255 
    256 

~/.pyenv/versions/3.6.6/envs/py36/lib/python3.6/site-packages/pycuda/compiler.py in compile_plain(source, options, keep, nvcc, cache_dir, target)
    135         raise CompileError("nvcc compilation of %s failed" % cu_file_path,
    136                 cmdline, stdout=stdout.decode("utf-8", "replace"),
--> 137                 stderr=stderr.decode("utf-8", "replace"))
    138 
    139     if stdout or stderr:

CompileError: nvcc compilation of /tmp/tmp4kbpczlc/kernel.cu failed
[command: nvcc --cubin -arch sm_61 -I -I/root/.pyenv/versions/3.6.6/envs/py36/lib/python3.6/site-packages/pycuda/cuda kernel.cu]
[stderr:
/usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/detail/cstdint.h(63): error: this declaration may not have extern "C" linkage

/usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/detail/cstdint.h(64): error: this declaration may not have extern "C" linkage

/usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/detail/cstdint.h(67): error: this declaration may not have extern "C" linkage

/usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/detail/cstdint.h(68): error: this declaration may not have extern "C" linkage

/usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/detail/cstdint.h(71): error: this declaration may not have extern "C" linkage

/usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/detail/cstdint.h(72): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/memoryfwd.h(63): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/memoryfwd.h(66): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/memoryfwd.h(70): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/stringfwd.h(52): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/stringfwd.h(55): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/stringfwd.h(58): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/stringfwd.h(63): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/stringfwd.h(64): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/stringfwd.h(69): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/postypes.h(111): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/postypes.h(214): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/postypes.h(219): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/iosfwd(76): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/iosfwd(79): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/iosfwd(82): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/iosfwd(85): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/iosfwd(88): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/iosfwd(94): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/iosfwd(98): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/iosfwd(102): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/iosfwd(106): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/iosfwd(112): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/iosfwd(115): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/iosfwd(118): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/iosfwd(121): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/iosfwd(124): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/iosfwd(127): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/ext/numeric_traits.h(54): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/ext/numeric_traits.h(67): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/ext/numeric_traits.h(70): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/ext/numeric_traits.h(73): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/ext/numeric_traits.h(76): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/ext/numeric_traits.h(99): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/ext/numeric_traits.h(111): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/ext/numeric_traits.h(114): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/ext/numeric_traits.h(117): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/ext/numeric_traits.h(120): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/ext/numeric_traits.h(123): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/stl_pair.h(83): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/stl_pair.h(86): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/stl_pair.h(94): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/stl_pair.h(154): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/stl_pair.h(197): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/stl_pair.h(441): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/stl_pair.h(447): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/stl_pair.h(454): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/stl_pair.h(460): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/stl_pair.h(466): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/stl_pair.h(472): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/stl_pair.h(481): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/stl_pair.h(516): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/stl_iterator_base_types.h(116): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/stl_iterator_base_types.h(143): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/stl_iterator_base_types.h(146): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/stl_iterator_base_types.h(161): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/stl_iterator_base_types.h(177): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/stl_iterator_base_types.h(188): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/stl_iterator_base_types.h(202): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/stl_iterator_base_types.h(231): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/stl_iterator_base_funcs.h(71): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/stl_iterator_base_funcs.h(72): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/stl_iterator_base_funcs.h(77): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/stl_iterator_base_funcs.h(95): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/stl_iterator_base_funcs.h(109): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/stl_iterator_base_funcs.h(115): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/stl_iterator_base_funcs.h(135): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/stl_iterator_base_funcs.h(145): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/stl_iterator_base_funcs.h(156): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/stl_iterator_base_funcs.h(172): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/stl_iterator_base_funcs.h(195): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/stl_iterator_base_funcs.h(206): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/stl_iterator_base_funcs.h(218): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/ptr_traits.h(44): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/ptr_traits.h(48): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/ptr_traits.h(53): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/ptr_traits.h(57): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/ptr_traits.h(61): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/ptr_traits.h(66): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/ptr_traits.h(69): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/ptr_traits.h(77): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/ptr_traits.h(122): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/ptr_traits.h(146): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/stl_iterator.h(100): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/stl_iterator.h(297): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/stl_iterator.h(303): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/stl_iterator.h(309): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/stl_iterator.h(315): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/stl_iterator.h(321): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/stl_iterator.h(327): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/stl_iterator.h(335): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/stl_iterator.h(341): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/stl_iterator.h(347): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/stl_iterator.h(353): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/stl_iterator.h(359): error: this declaration may not have extern "C" linkage

Error limit reached.
100 errors detected in the compilation of "/tmp/tmpxft_000013b3_00000000-6_kernel.cpp1.ii".
Compilation terminated.
]
import pycuda.autoinit, pycuda.driver
from pycuda.compiler import SourceModule
import numpy
import time

mod = SourceModule('''
#include <thrust/random.h>
extern "C" {
__global__ void test_rand(int numRand, float *samples)
{
  int threadID = blockIdx.x * gridDim.x + threadIdx.x;
  thrust::default_random_engine rng;
  rng.discard(numRand * threadID);
  
  thrust::uniform_real_distribution<float> rand01(0,1);

  float acc=0.0;

  for (int i=0; i < numRand; i++) {
	float r = rand01(rng);
	acc += r;
  }
  samples[threadID] = acc/numRand;  // Normalize back to range [0,1)
}
}
''', include_dirs=[''])

test_rand = mod.get_function('test_rand')
### Compute many sums of random numbers
numRand = 512
threads_per_block = 256
blocks = 512

threads = threads_per_block * blocks
print ('Sampling sum of', numRand, 'random numbers', threads, 'times.')
samples = numpy.zeros(threads, dtype=numpy.float32)

start = time.time()
test_rand(numpy.int32(numRand), pycuda.driver.Out(samples), grid=(blocks,1), block=(threads_per_block,1,1))
stop = time.time()
print ('Execution+copy time = %1.1f msec' % ( (stop-start) * 1000.0,))

### Look at results in a lame text-only way
### Squint hard!  Central Limit Theorem says this is approximately a Gaussian.
hist, bin_edges = numpy.histogram(samples, bins=126, range=(0.3, 0.7))
print ('Distribution:', hist)
---------------------------------------------------------------------------
CompileError                              Traceback (most recent call last)
<ipython-input-18-9fd4be8a6650> in <module>
     24 }
     25 }
---> 26 ''', include_dirs=[''])
     27 
     28 test_rand = mod.get_function('test_rand')

~/.pyenv/versions/3.6.6/envs/py36/lib/python3.6/site-packages/pycuda/compiler.py in __init__(self, source, nvcc, options, keep, no_extern_c, arch, code, cache_dir, include_dirs)
    289 
    290         cubin = compile(source, nvcc, options, keep, no_extern_c,
--> 291                 arch, code, cache_dir, include_dirs)
    292 
    293         from pycuda.driver import module_from_buffer

~/.pyenv/versions/3.6.6/envs/py36/lib/python3.6/site-packages/pycuda/compiler.py in compile(source, nvcc, options, keep, no_extern_c, arch, code, cache_dir, include_dirs, target)
    252         options.append("-I"+i)
    253 
--> 254     return compile_plain(source, options, keep, nvcc, cache_dir, target)
    255 
    256 

~/.pyenv/versions/3.6.6/envs/py36/lib/python3.6/site-packages/pycuda/compiler.py in compile_plain(source, options, keep, nvcc, cache_dir, target)
    135         raise CompileError("nvcc compilation of %s failed" % cu_file_path,
    136                 cmdline, stdout=stdout.decode("utf-8", "replace"),
--> 137                 stderr=stderr.decode("utf-8", "replace"))
    138 
    139     if stdout or stderr:

CompileError: nvcc compilation of /tmp/tmpi0_p9zln/kernel.cu failed
[command: nvcc --cubin -arch sm_61 -I -I/root/.pyenv/versions/3.6.6/envs/py36/lib/python3.6/site-packages/pycuda/cuda kernel.cu]
[stderr:
/usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/detail/cstdint.h(63): error: this declaration may not have extern "C" linkage

/usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/detail/cstdint.h(64): error: this declaration may not have extern "C" linkage

/usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/detail/cstdint.h(67): error: this declaration may not have extern "C" linkage

/usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/detail/cstdint.h(68): error: this declaration may not have extern "C" linkage

/usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/detail/cstdint.h(71): error: this declaration may not have extern "C" linkage

/usr/local/cuda/bin/../targets/x86_64-linux/include/thrust/detail/cstdint.h(72): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/memoryfwd.h(63): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/memoryfwd.h(66): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/memoryfwd.h(70): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/stringfwd.h(52): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/stringfwd.h(55): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/stringfwd.h(58): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/stringfwd.h(63): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/stringfwd.h(64): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/stringfwd.h(69): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/postypes.h(111): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/postypes.h(214): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/postypes.h(219): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/iosfwd(76): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/iosfwd(79): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/iosfwd(82): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/iosfwd(85): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/iosfwd(88): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/iosfwd(94): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/iosfwd(98): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/iosfwd(102): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/iosfwd(106): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/iosfwd(112): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/iosfwd(115): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/iosfwd(118): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/iosfwd(121): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/iosfwd(124): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/iosfwd(127): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/ext/numeric_traits.h(54): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/ext/numeric_traits.h(67): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/ext/numeric_traits.h(70): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/ext/numeric_traits.h(73): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/ext/numeric_traits.h(76): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/ext/numeric_traits.h(99): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/ext/numeric_traits.h(111): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/ext/numeric_traits.h(114): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/ext/numeric_traits.h(117): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/ext/numeric_traits.h(120): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/ext/numeric_traits.h(123): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/stl_pair.h(83): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/stl_pair.h(86): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/stl_pair.h(94): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/stl_pair.h(154): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/stl_pair.h(197): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/stl_pair.h(441): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/stl_pair.h(447): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/stl_pair.h(454): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/stl_pair.h(460): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/stl_pair.h(466): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/stl_pair.h(472): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/stl_pair.h(481): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/stl_pair.h(516): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/stl_iterator_base_types.h(116): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/stl_iterator_base_types.h(143): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/stl_iterator_base_types.h(146): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/stl_iterator_base_types.h(161): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/stl_iterator_base_types.h(177): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/stl_iterator_base_types.h(188): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/stl_iterator_base_types.h(202): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/stl_iterator_base_types.h(231): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/stl_iterator_base_funcs.h(71): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/stl_iterator_base_funcs.h(72): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/stl_iterator_base_funcs.h(77): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/stl_iterator_base_funcs.h(95): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/stl_iterator_base_funcs.h(109): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/stl_iterator_base_funcs.h(115): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/stl_iterator_base_funcs.h(135): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/stl_iterator_base_funcs.h(145): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/stl_iterator_base_funcs.h(156): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/stl_iterator_base_funcs.h(172): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/stl_iterator_base_funcs.h(195): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/stl_iterator_base_funcs.h(206): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/stl_iterator_base_funcs.h(218): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/ptr_traits.h(44): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/ptr_traits.h(48): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/ptr_traits.h(53): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/ptr_traits.h(57): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/ptr_traits.h(61): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/ptr_traits.h(66): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/ptr_traits.h(69): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/ptr_traits.h(77): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/ptr_traits.h(122): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/ptr_traits.h(146): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/stl_iterator.h(100): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/stl_iterator.h(297): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/stl_iterator.h(303): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/stl_iterator.h(309): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/stl_iterator.h(315): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/stl_iterator.h(321): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/stl_iterator.h(327): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/stl_iterator.h(335): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/stl_iterator.h(341): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/stl_iterator.h(347): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/stl_iterator.h(353): error: this declaration may not have extern "C" linkage

/usr/include/c++/7/bits/stl_iterator.h(359): error: this declaration may not have extern "C" linkage

Error limit reached.
100 errors detected in the compilation of "/tmp/tmpxft_000013c1_00000000-6_kernel.cpp1.ii".
Compilation terminated.
]

PyCADAプログラミングは色々と奥が深い。というか、難解である。

スポンサーリンク
スポンサーリンク