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

How to use this library? #843

Closed
ChristianOL opened this issue Aug 26, 2018 · 4 comments
Closed

How to use this library? #843

ChristianOL opened this issue Aug 26, 2018 · 4 comments

Comments

@ChristianOL
Copy link

Is there an example how to install and use this library? I have downloaded 5.0.0 release,
I am using DevC++ 5.11 to compile a simple program. I copied all headers and the src/format.cc files. Are there more steps needed? This is my code, when compiling I, get a bunch of errors.

Code:
#include
#include "fmt/format.h"
#include "fmt/ostream.h"
#include "fmt/core.h"
int main() {
fmt::print("The answer is {}.", 42);
return 0;
}

First error by compiler:
17 30 C:\Users\chris\fmt-5.0.0\include\fmt\time.h [Error] macro "localtime_r" requires 2 arguments, but only 1 given.

Code lines marked by compiler on time.h file:
#ifndef FMT_TIME_H_
#define FMT_TIME_H_
#include "format.h"
#include
FMT_BEGIN_NAMESPACE
namespace internal{
inline null<> localtime_r(...) { return null<>(); } // <-- ERROR IS MARKED HERE
inline null<> localtime_s(...) { return null<>(); }
inline null<> gmtime_r(...) { return null<>(); }
inline null<> gmtime_s(...) { return null<>(); }
}

Screenshot:
fmt_error

@vitaut
Copy link
Contributor

vitaut commented Aug 26, 2018

Please see http://fmt.dev/latest/usage.html and http://fmt.dev/latest/api.html.

For fmt::print you just need to include fmt/core.h.

As for the issue with localtime_r, what OS and compiler do you use?

@ChristianOL
Copy link
Author

Previously I tried to build the library with CMAKE but I still got a bunch of errors. I was wandering if there is an easier way like just using the header files? (more simple sort of step by step help).
Is this a different option rather than building a library? "Header-only usage with CMake".
Sorry am not very familiar with this.

Thanks!
Windows 10 Home Single Language
MinGW64

@vitaut
Copy link
Contributor

vitaut commented Aug 28, 2018

The localtime_r issue should be fixed in e4cf404.

You can enable the header-only mode by defining the FMT_HEADER_ONLY macro to 1 in which case you don't need to compile the library.

@ChristianOL
Copy link
Author

Thank you very much. I was able to use the fmt. I incorrectly understood that creating a library was needed. I see it is optional.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants