Get C code output

2023-09-08 Thread PMunch
You can definitely do both. Maybe having a look at how Ratel builds for various microcontrollers can give you an idea?

Get C code output

2023-09-08 Thread SpotlightKid
https://nim-lang.org/docs/backends.html#interfacing

Get C code output

2023-09-08 Thread c4UlMu
I want to write code for Flipper Zero. They write code in C Is it possible to write all the code in nim and then get C output and compile it with their tools? Or maybe you can show me articles or tutorial how to integrate nim with external C tools ?

how to properly set environment variables

2023-09-08 Thread hevaf
thank you. this works for me now !

why float casting is not working ?

2023-09-08 Thread PMunch
Just for completeness sake you could also just type out a floating point number: var x = 1.0 Run

why float casting is not working ?

2023-09-08 Thread cblake
A quick `grep` suggests about 210 packages in ~560 files use expression `type()`. So, I don't know.. that's like 10% of Nimble packages. Of course, there are definitely many packages not in the nimble index, and also dark code that is not even public. I am aware of at least order(100) subcommand

why float casting is not working ?

2023-09-08 Thread cblake
I think `typeof` is better in an expression context like above -- sorry -- and `type` use there is "deprecated" (but works obviously if you compile & run it). I have no idea what the timeline for really deprecating this use is or how much of the nimbleverse will break if it actually goes away.

why float casting is not working ?

2023-09-08 Thread maverk
what is the difference between `type()` and `typeof()` ???

why float casting is not working ?

2023-09-08 Thread maverk
so it just translate the binary of the given value to the desired type ?

why float casting is not working ?

2023-09-08 Thread maverk
yes i was confused since there are string and char and other built in functions for doing the same thing well i will avoid cast thanks brother much appreciated

why float casting is not working ?

2023-09-08 Thread Chronos
`cast` is essentially telling the compiler that X **_is_** of type Y, but because floats are represented differently in the compiler (due to how binary works), casting an integer to a float gives outputs like that, when you do `1.float` or `1'f`, it tells the compiler that you want to represent

CPU Benchmark test via Nim-compilation

2023-09-08 Thread inv2004
... do not have a chance ...

why float casting is not working ?

2023-09-08 Thread namisboss
I've seen talk of people suggesting renaming `cast` to `bitcast`, because that's what it does. You want a conversion which is done via `float(1)` or any of the variants juancarlospaco suggested (as they all are pretty much the same thing). In general you should never be using `cast`.

why float casting is not working ?

2023-09-08 Thread cblake
Also, you don't need the apostrophe `'` for `float` and `uint` (and maybe others): echo type(1f)," ",type(1u) Run And if you put the word "Nim" after the triple open quotes it will syntax-highlight your code on The Forum (if you did not know).

why float casting is not working ?

2023-09-08 Thread juancarlospaco
Use `1'f` or `1.float`.

why float casting is not working ?

2023-09-08 Thread maverk
can you please explain to me why the suffix is needed ? because i already gave the cast keyword the desired type i want to make of 1

why float casting is not working ?

2023-09-08 Thread dlesnoff
`cast` never does what you want. It should reinterpret bit by bit your number but it is unsafe.

why float casting is not working ?

2023-09-08 Thread maverk
var casting : float = cast[float](1) echo casting Run result : 4.940656458412465e-324 Run why is this happening ? how does the `cast` keyword work on which types ?

what are the equivalent libraries to these ?

2023-09-08 Thread termer
It's also worth noting that if there's a C or C++ library you want to use (either OS libraries like those, or a 3rd party library), it's very easy to interface with it. You can find information on importing C functions here

what are the equivalent libraries to these ?

2023-09-08 Thread Araq
winlean.nim, os.nim, system.nim. It's generally better to think "how do I do X in Nim" instead of "how do I translate this arcane uppercased code from 1990 to Nim".

how to properly set environment variables

2023-09-08 Thread juancarlospaco
https://nim-lang.github.io/Nim/envvars.html#getEnv%2Cstring%2Cstring

how to properly set environment variables

2023-09-08 Thread hevaf
Hi, Would someone here know how to properly set and get environment variables in linux/windows in nim 2.0 ? I am not getting anywhere with existing examples :-( Any help /pointers appreciated. Thank you.

what are the equivalent libraries to these ?

2023-09-08 Thread maverk
STDIO.H STDLIB.H UNISTD.H WINSOK2.H WINDOWS.H WINUSER.H WININEXT.H WINDOWSX.H STRING.H SYS/STAT.H SYS.TYPES.H Run in nim language what are they ?

CPU Benchmark test via Nim-compilation

2023-09-08 Thread inv2004
Yes, it is pinned version of 1.6.something if I remember correct. The commit `fac5bae7b7d87aeec48c7252029c2852ee157ac9` Just because it make no sense to compare different codes build speed

This Month with Nim: July and August 2023

2023-09-08 Thread obtaindad
Thank you for sharing instructions on how to bring a project to the community. Very useful information for me. I will follow the steps you shared and hope it works [flappy bird](https://flappy-bird.co/)

Teaching old C code new tricks with Nim

2023-09-08 Thread PMunch
New article out on my website for those interested: Diving deep to neatly wrap C libraries, this time by linking in override functions!

CPU Benchmark test via Nim-compilation

2023-09-08 Thread dlesnoff
Why don't you add the Nim version to these benchmarks? Are you using a specific compiler version?

how to get the string of all command line parameters except the first parameter ?

2023-09-08 Thread hevaf
this is wonderful, thank you very much for your example !! I am still learning the ropes here

How can I shorten the compile time?

2023-09-08 Thread PMunch
Have you tried `nim e app.nim`? That runs it as a NimScript file instead of a Nim file. Of course this has all the caveats of NimScript.