I would like to know how i could use std::cout in a file that does not contains a class and which is a part of a project that contain already a main () in another file.
I am trying something in the file :
1 2 3 4 5 6
//FileWithoutAMain.hpp
#include <iostream>
#define LOG(x) (std::cout << (x) << std::endl)
LOG("This is file is used in the .exe");
Huh? What's that supposed to be for? When did you intend this to be printed? If it's at compile time, I think most compilers supply pragmas for that (although you don't wanna do that, output should be reserved to errors and warnings).
You can use std::cout in any file as long as you call it from a function.
If you want some code to be executed, you can hack this behaviour using some kind of weird initialization.
But I'm not so sure what you are really trying to achieve there...
I have a library (developed by someone else) that contains a lots of files (themselves containing namespaces) and i would like to have a kind of flag that will indicate me when this file/namespaces are used.
// some header file that may be included by other headers
#ifndef GUARD_IDENTIFIER
#define GUARD_IDENTIFIER
// code
#endif
In my code do you mean?
#ifdef GUARD_IDENTIFIER
// the file abov has been included (either directly or indirectly) std::cout << "the file abov has been included (either directly or indirectly)" ;