Let's test ourselves: Talking in code.

Pages: 12
Fredbill wrote:
Can someone compile and place the executable here? I'm lazy and I don't want to get gcc or make a new project.

Safer to use http://www.ideone.com though some things do have issues on it. Apparently Mats code timed out, but I trusted him enough to compile it to get "replies" as the result.

@chrisname
Apparently you have a special compiler as ideone gives the same error Zorg says:

http://ideone.com/rOo9ld

Also, yes I did compile it under my OS and upon running I too get the same error.
Last edited on
@BHX
I mentioned about ideone already. It won't work because they have threads disabled (otherwise anyone could write a program which creates so many threads that it kills the OS).

ideone wrote:
terminate called after throwing an instance of 'std::system_error'
what(): Enable multithreading to use std::thread: Operation not permitted

Clearly this is saying that threading is not enabled.

Maybe you need to enable it manually. Try adding -pthread to your command-line.
closed account (L6b7X9L8)
-pthread did the job it didn't crash!
chrisname wrote:

Maybe you need to enable it manually. Try adding -pthread to your command-line.

How peculiar, I did build it with -pthread but got the error. This is the output in my terminal. It gave me the error three times, was about to just chalk it up to just a fluke, but then it started working.


:~$ cd projects/cpp/tests
:~/projects/cpp/tests$ ./chrisname
terminate called after throwing an instance of 'std::system_error'
  what():  Enable multithreading to use std::thread: Operation not permitted
Aborted
:~/projects/cpp/tests$ ./chrisname
terminate called after throwing an instance of 'std::system_error'
  what():  Enable multithreading to use std::thread: Operation not permitted
Aborted
:~/projects/cpp/tests$ ./chrisname
terminate called after throwing an instance of 'std::system_error'
  what():  Enable multithreading to use std::thread: Operation not permitted
Aborted
:~/projects/cpp/tests$ ./chrisname
Message: hello, world
:~/projects/cpp/tests$ ./chrisname
Message: hello, world
:~/projects/cpp/tests$ time ./chrisname
Message: hello, world

real	0m9.628s
user	0m15.320s
sys	0m3.732s

:~/projects/cpp/tests$


Added the time print out.
*shrugs* I don't know why it didn't work at first, but has worked everytime since. I'll just chalk it up to being a fluke for now and hope it doesn't show up anymore.
Last edited on
I guess my toolchain links against pthread by default and yours don't.

@BHX
That's really weird. Is it possible you ran it the first three times before g++ had finished compiling it? Or maybe your OS was running a cached version.

[edit] Here's my documented version of the code explaining how it works: http://codepad.org/Deu3k1CX
Last edited on
@chrisname
It is possible. Just glad it works now as I didn't want to spend the night finding a solution for it.
closed account (N36fSL3A)
@chrisname
http://prntscr.com/3l2yn2
Last edited on
@Fredbill try compiling it as a c++ program (use g++ not gcc)

EDIT: The problem could also be the thread model used by your version of mingw. Run g++ -v, if it says thread model win32 then that's probably the problem.
Last edited on
closed account (N36fSL3A)
I'm using the -pthread tag.
He means does g++ -v return win32 thread model or Posix thread model. Pthread is *nix. Depending on the thread model it will need something else.


:~/projects/cpp$ g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.8/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 4.8.2-14' 
--with-bugurl=file:///usr/share/doc/gcc-4.8/README.Bugs 
--enable-languages=c,c++,java,go,d,fortran,objc,obj-c++ 
--prefix=/usr --program-suffix=-4.8 --enable-shared --enable-linker-build-id 
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix 
--with-gxx-include-dir=/usr/include/c++/4.8 --libdir=/usr/lib 
--enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes 
--enable-gnu-unique-object --disable-libmudflap --enable-plugin 
--with-system-zlib --disable-browser-plugin --enable-java-awt=gtk 
--enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64/jre
 --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64 
--with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.8-amd64 
--with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar 
--enable-objc-gc --enable-multiarch --with-arch-32=i586 --with-abi=m64 
--with-multilib-list=m32,m64,mx32 --with-tune=generic --enable-checking=release 
--build=x86_64-linux-gnu --host=x86_64-linux-gnu 
--target=x86_64-linux-gnu
Thread model: posix
gcc version 4.8.2 (Debian 4.8.2-14) 
Last edited on
A ton of obfuscated , strange c code here : (of which a lot complies with c++ standard directly or with little modification...)

www.ioccc.org/
closed account (L6b7X9L8)
^

http://www.ioccc.org/2013/birken/birken.c

That's just beautiful!
-lpthread:

1
2
3
4
5
6
$ g++ -std=c++11 chrisname.cpp -o fun && fun
terminate called after throwing an instance of 'std::system_error'
  what():  Enable multithreading to use std::thread: Operation not permitted
Aborted
$ g++ -std=c++11 chrisname.cpp -lpthread -o fun && fun
Message: hello, world


On my linux machine, at least.

Edit: hmm, just -pthread works too...
Last edited on
With that link to the obfuscated code you posted I keep getting this as the output on IDEone:
IDEone cout wrote:
[2J[?25l                                                                                                                                   [?25h


Pasted as quote because [output] stretches the box really far =)
Last edited on
@SatsumaBenji
Those are ANSI terminal codes to set the colour of text. ideone could convert them to HTML but obviously it doesn't.
@SatsumaBenji
http://prntscr.com/3lkcig

That is what I got when I compiled it.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <iostream>

int main()
{
	std::cout << "\033[2J[?25l    
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
 [?25h" << std::endl;
	
}
Last edited on

http://www.ioccc.org/2013/birken/birken.c

That's just beautiful!
With that link to the obfuscated code you posted I keep getting this as the output on IDEone:

Its a tetris game, you have to compile it yourself to play it ...

Here's another good one , if you got linux (it uses X11) ...
http://www.ioccc.org/years.html#1998
See banks,
First read the banks.hint,then download the makefile,some sceneries,and the c source code and run
$ make banks

Some examples :

$ cat horizon.sc bb.sc | ./banks
$ cat horizon.sc pittsburgh.sc | ./banks

Its really amazing how he did a flight simulator in such lines of code (code that even looks like a plane :) ).
Last edited on
Okay, pretty cool then... Although I'm not sure how you use Tetris for communication ;D
@SatsumaBenji
That is easy! Instead of the tetriminos, make it a chat like program where the text of the replies become your pieces, but pause when you start typing your reply ;).
Topic archived. No new replies allowed.
Pages: 12