|
It’s been awhile since I’ve used Visual Studio. Is there seriously no way to stop it from throwing IntelliSense errors on *.inl files?
xgalaxy fucked around with this message at 04:44 on Oct 12, 2019 |
# ? Oct 12, 2019 04:42 |
|
|
# ? May 17, 2024 11:26 |
|
peepsalot posted:I got a cmake / toolchain question. I have a project that uses cmake and I want to have it build with all clang/llvm tools. If you wanna see what your compile is really doing run cmake like usual then run code:
|
# ? Oct 12, 2019 05:49 |
|
I need to know how many bits a given unsigned integer fits into. I have been told that c++20 will have something for this: http://eel.is/c++draft/bit.pow.two#itemdecl:4 But I'm limited to c++14 for this project. I want this to be as portable as possible across compilers (gcc, clang, msvc) and architectures (x86 or arm, 32 or 64bit). The simplest thing would be to loop through powers of two, shifting left each iteration and checking if (pow2 >= value), but I would like to use intrinsics / builtins wherever possible. I think I'll only need it on size_t so basically it needs to support either uint32_t or uint64_t afaik. GCC (and clang i think) can use pre:__builtin_clz[l[l]] So I'm wondering how hard would it be to write any equivalent template while limited to c++14. The annoying thing is that these builtins have input types like unsigned int, unsigned long, unsigned long long rather than explicitly sized uint32_t etc. So my problem is I don't really understand how to implement static checks well enough to write something that chooses the correct builtin or intrinsic based on the provided type. This all seems incredibly complicated for what should be a really simple operation.
|
# ? Nov 1, 2019 21:44 |
|
peepsalot posted:I need to know how many bits a given unsigned integer fits into. Bit Twiddling Hacks
|
# ? Nov 1, 2019 21:53 |
|
Note that the ceil(log2(x)) function for finding the minimum required bit count is still 32-bit specific. You'll need to make specific versions for other word sizes if you want to handle char, short, uint64_t, size_t, etc. This isn't that hard, but it's a step. I guess you'd then do some basic enable_if<is_unsigned<T>::value && sizeof(T) == sizeof(uint32_t)>-ish SFINAE to resolve to the right version for unsigned types of whatever widths you care about and fail for signed or non-integral types. Not sure if there's a better way to accomplish that.
|
# ? Nov 2, 2019 04:00 |
|
I want to get the current time. Not the time on the user's machine, but like the actual time. It seems I need to create an SNTP or NTP client. Is there a library that just does this? Because I can find a lot of snippets that feel dubious and many don't compile on Windows because I don't have sys/socket.h like this one: https://stackoverflow.com/questions/9326677/is-there-any-c-c-library-to-connect-with-a-remote-ntp-server I'd rather there were a nice library instead of copy and pasting some random poo poo from stackoverflow.
|
# ? Nov 2, 2019 15:22 |
|
Just grab the reference implementation (or an appropriate port) from ntp.org?
|
# ? Nov 2, 2019 15:32 |
|
I don't think that is what I want. I looked at it and didn't really know what I was looking at. Actually I might just use https://timezonedb.com e: well that just opens another can of worms. What's a simple way to do an http request? I looked at libcurl and it looks like overkill. There are a few "header only" libraries but they don't build for whatever reason. baby puzzle fucked around with this message at 17:07 on Nov 2, 2019 |
# ? Nov 2, 2019 16:04 |
|
baby puzzle posted:e: well that just opens another can of worms. What's a simple way to do an http request? I looked at libcurl and it looks like overkill. There are a few "header only" libraries but they don't build for whatever reason.
|
# ? Nov 2, 2019 17:16 |
|
roomforthetuna posted:You can just use a socket, write "GET [path] HTTP/1.0\nHost: [hostname]\n\n" to it, and parse what comes back. If you don't mind assuming success you can just read blindly until you hit two newlines in a row, then everything after that is the content. Next you'll be suggesting they write their own TLS implementation from scratch.
|
# ? Nov 2, 2019 17:30 |
|
I think I figured out what my compile issues were with using sockets. I had to use WIN32_LEAN_AND_MEAN, but then fix some spots where I needed that. So I think I should be able to use one of those header-only libraries now. e: yeah this one builds now so I should be good: https://github.com/yhirose/cpp-httplib
|
# ? Nov 2, 2019 17:35 |
|
pseudorandom name posted:Next you'll be suggesting they write their own TLS implementation from scratch. What I was really suggesting is "just use the library". Edit: Also note that the "header-only" option is only actually header-only with no SSL or compression support, otherwise it's hidden dependencies on other libraries being present. roomforthetuna fucked around with this message at 17:50 on Nov 2, 2019 |
# ? Nov 2, 2019 17:39 |
|
Well none of the small libraries that I tried worked and I have no idea why. Maybe I'll have to use libcurl? But I don't even know where to start with that. I would like to know how to do this kind of thing because it seems generally useful.
|
# ? Nov 2, 2019 18:23 |
|
Once you figure out how to get UTC, you have to convert it to local time, which can be an adventure in itself.
|
# ? Nov 2, 2019 18:29 |
|
baby puzzle posted:Well none of the small libraries that I tried worked and I have no idea why. Maybe I'll have to use libcurl? But I don't even know where to start with that. You ask the OS what time it is right now.
|
# ? Nov 2, 2019 18:30 |
|
If you want to do a GET w/ SSL support and everything else, have a look at https://github.com/Microsoft/cpprestsdk If the requirement is ntp why not set up ntp on the host itself?
|
# ? Nov 3, 2019 14:54 |
|
Anyone know a good tool that's not Java based to help find duplicate or unused code across a C/C++ project?
|
# ? Nov 9, 2019 06:20 |
|
peepsalot posted:Anyone know a good tool that's not Java based to help find duplicate or unused code across a C/C++ project? http://clang-analyzer.llvm.org/scan-build.html ?
|
# ? Nov 9, 2019 18:12 |
|
While that looks like a useful static analysis tool, I'm not seeing any specific checker for it to find duplicated code, but maybe I'm missing something?
|
# ? Nov 9, 2019 23:59 |
|
This is my programming homework, I've looked in the book and looked online. Can anyone tell me why my program isn't A.) finding the smallest number in the arrays (It's always returning the number I put into it. and B) isn't adding the 2 arrays together. and C.) isn't finding the largest or smallest numbers in the later arrays. https://docs.google.com/document/d/1z_m9hHmQ6EvDii0sBf8XWwvl1yS7uMhyRZIOpIsFfOw/edit?usp=sharing
|
# ? Nov 10, 2019 04:14 |
|
Turtlicious posted:This is my programming homework, I've looked in the book and looked online. Have you tried stepping through the code in a debugger and seeing what the values of R and C are in each loop? In almost all of your loops, you forget to set C to 0 as the starting value.
|
# ? Nov 10, 2019 05:40 |
|
ullerrm posted:Have you tried stepping through the code in a debugger and seeing what the values of R and C are in each loop? thank you so much. Turtlicious fucked around with this message at 05:52 on Nov 10, 2019 |
# ? Nov 10, 2019 05:50 |
|
You should always be building C/C++ code with a ton of warnings on (and actually paying attention to them). There are so many things about these languages that really just should not be allowed and which are only caught by warnings. It's far beyond "best practice"; anybody writing code in these languages without paying attention to warnings is just being foolish. That is true even for highly experienced programmers; as a novice, it will save you again and again and again. If you are using GCC or Clang, the option you want is -Wall. That will make some somewhat pedantic complaints that you might find annoying, but trust me, just fix them anyway so that you get into the habit of treating warnings as serious.
|
# ? Nov 10, 2019 06:24 |
|
-Wall -Werror
|
# ? Nov 10, 2019 14:45 |
|
I tried this tool and got some nice python UnicodeDecode exceptions in the output data but I can't figure out where I should report bugs.
|
# ? Nov 10, 2019 15:48 |
|
-Wall is also, despite the name, only the warnings that gcc developers think should always be turned on, not everything. If you're using gcc you should look through the warnings documentation and choose a set that works for you I myself am partial to: -Wall -Wextra -Wpedantic -Wcast-qual -Wdouble-promotion -Warray-bounds=2 -Wtrampolines -Wunsafe-loop-optimizations -Wconversion -Wparentheses -Wlogical-op Foxfire_ fucked around with this message at 01:57 on Nov 11, 2019 |
# ? Nov 11, 2019 01:33 |
|
-Wgive-me-all-the-warnings-you-have -Wno-thats-too-many
|
# ? Nov 11, 2019 01:40 |
|
That sounds useful, sounds like I should switch off Eclipse.
|
# ? Nov 11, 2019 01:40 |
|
Does GCC have an installer?
|
# ? Nov 11, 2019 06:32 |
If you use Eclipse for C++ development and you don't remember installing GCC or Clang yourself, then Eclipse installed it for you. It will be using one of those two for C++ compiler already.
|
|
# ? Nov 11, 2019 06:44 |
|
Foxfire_ posted:-Wall is also, despite the name, only the warnings that gcc developers think should always be turned on, not everything. If you're using gcc you should look through the warnings documentation and choose a set that works for you I found this and set all the warnings on, but I can't add all the stuff you have on through Eclipse.
|
# ? Nov 11, 2019 07:42 |
|
Not an eclipse user but there should be space somewhere to pass in arbitrary flags, maybe in Miscellaneous?
|
# ? Nov 11, 2019 07:46 |
|
Turtlicious posted:Does GCC have an installer? ./configure && make && sudo make install
|
# ? Nov 11, 2019 19:15 |
|
There we go, it was in miscellaneous.
|
# ? Nov 11, 2019 21:14 |
|
I have this struct:code:
code:
code:
How can I get both the constructor and the curly-bracket initializer list to work?
|
# ? Nov 22, 2019 14:59 |
|
You need to add a constructor that accepts a float2. When you have no constructor, your struct is eligible for aggregate initialization, where the values in your initializer list are just copied into the fields of the struct. Once you add a constructor, that no longer applies, so the compiler needs to match up your initializer list against an appropriate constructor.
|
# ? Nov 22, 2019 15:12 |
|
Ok, that's easier than I thought it was going to be. The curly bracket construction still works. Thanks.
|
# ? Nov 22, 2019 15:20 |
|
I feel pretty dumb and need some help. First of all, ARM32 architecture. I have this: code:
So it's just converted to a big list of #defines. eg/ code:
How in the fresh hell do I get C to let me safely (in regards to sb) do some pointer arithmetic to sb to access what I need? I'm fighting with the compiler over casting. It's very anal retentive. I'm returning to an old project and want to see if I can write some HAL code in C instead of assembly. Most of the hardware is straightforward, but some is an absolute mindfuck that must have been designed by a sadist. In that cas it'd be nice to be able to abstract myself a little. e: Modified rubber ducky debugging works again. Ie posting. Here's a pointless test function that builds. code:
General_Failure fucked around with this message at 06:11 on Dec 2, 2019 |
# ? Dec 2, 2019 05:39 |
|
Okay, so your magic global register contains a pointer to a structure with fields at the given offsets, which you want to read? The offsets in your example are all multiples of 4; are they supposed to be offsets in bytes or in 32-bit chunks? Assuming they’re in bytes, you should declare sb as a char* and then do something like: C++ code:
|
# ? Dec 2, 2019 09:58 |
|
|
# ? May 17, 2024 11:26 |
|
rjmccall posted:Okay, so your magic global register contains a pointer to a structure with fields at the given offsets, which you want to read? This little dance is needed when working with the HAL because it's below a decent chunk of the OS functionality. The static workspace is a construct which the developer (me in this case) creates and uses to hold the sacred values which keep the OS' poo poo together. quote:The offsets in your example are all multiples of 4; are they supposed to be offsets in bytes or in 32-bit chunks? In the case of my toy example, IIRC there are five UARTS. I have the base addresses stored sequentially. Hence using the shift to get word offsets from HALUART_Log. I could have a switch and reference each offset by name, but why? Anyway the UART was one of the very first things I did a couple of years ago or so in assembly and it works fine. I just chose it as an example because it's simple but representative. quote:
|
# ? Dec 2, 2019 23:02 |