Click here to Skip to main content
Click here to Skip to main content
Go to top

Ideone.com pastebin and online compiler with support for 40 programming languages

, 13 Dec 2011
Rate this:
Please Sign up or sign in to vote.
Ideone.com pastebin and online compiler with support for 40 programming languages
What to do when you want to test a code snippet and you do not have the development environment at hand? Or if you just want to try out stuff shown here at CodeProject in a language that you do not normally use?
 
Well, recently when I was fiddling with my current article (g2log) I wanted to try out std::atomic but all I had at hand was basically a borrowed computer with www access.
 
Well, just pure Google luck gave way to ideone.com and I could try out std::atomic. I chose C++0x as language and quickly I could try out this (click here for the full code).
 
namespace internal
{
  std::atomic<bool> g_log_level_status[4]; // DEBUG, INFO, WARNING, FATAL
}
 
void setLogLevel(int level, bool enabled)
{
  assert((level >= DEBUG) && (level <= FATAL));
  (internal::g_log_level_status[level]).store(enabled, std::memory_order_release);
}
 
bool logLevel(int level)
{
  assert((level >= DEBUG) && (level <= FATAL));
  bool status = (internal::g_log_level_status[level]).load(std::memory_order_acquire);
  return status;
}
 
#define G2_LOG_INFO  LogMessage(__FILE__,__LINE__,__PRETTY_FUNCTION__, "INFO")
#define LOG(level) if(logLevel(level)) G2_LOG_##level.messageStream()
// .... etc etc

int main()
{
   setLogLevel(INFO, true);
   LOG(INFO)<< "TEST asf" << std::endl;
   setLogLevel(INFO, false);
   LOG(INFO) << "TEST asf 2 (should not be shown)" << std::endl;
   setLogLevel(INFO, true);
   LOG(INFO) << "TEST asf 3 (SHOULD be shown)" << std::endl;
 
return 0;
}
 
With ideone.com output
TEST asf
TEST asf 3 (SHOULD be shown)
 
Real nice. Now I will try some C#, what about you?

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

KjellKod.cc
Software Developer (Senior) LogRhythm
United States United States
Enjoying Colorado! Family and intense software development.
 
Kjell is a driven developer with a passion for software development. His focus is on coding, boosting software development, improving development efficiency and turning bad projects into good projects.
 
Kjell was twice national champion in WUKO and semi-contact Karate and now he focuses his kime towards software engineering, everyday challenges and moose hunting while not being (almost constantly) amazed by his daughter and sons.

Comments and Discussions

 
GeneralReason for my vote of 5 Nice, clear, simple Pinmemberdragoshilbert18-Jan-12 9:40 
Reason for my vote of 5
Nice, clear, simple
GeneralGreat Great! 5! PinmemberPranit Kothari13-Dec-11 1:31 
GeneralReason for my vote of 5 None other than 5! can give PinmemberPranit Kothari13-Dec-11 1:31 
GeneralReason for my vote of 5 Very nice tip! :) PinmemberNuri Ismail12-Dec-11 23:14 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web04 | 2.8.140922.1 | Last Updated 13 Dec 2011
Article Copyright 2011 by KjellKod.cc
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid