Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Dren
Jan 5, 2001

Pillbug
I can't seem to find the project settings I need in KDevelop. It couldn't find the includes it needed so it prompted me to edit the custom include path, which I did, but now I can't get back to that menu.

I like the stuff I have figured out much better than Eclipse.

Adbot
ADBOT LOVES YOU

Marta Velasquez
Mar 9, 2013

Good thing I was feeling suicidal this morning...
Fallen Rib

Edison was a dick posted:

In my experience, most don't, instead opting to use their preferred text editor, make and GDB. To me, Linux itself is my IDE, though I've heard good things about Kdevelop recently.

This is the way I program.

The text editor in KDevelop is an embedded Kate window. It acts as a frontend for make and gdb, with code completion, project management, source control, patch reviewing, integrated Okteta (if you need hex editing), etc. It's a great convenience for someone who already treats Linux itself as an IDE.

Volguus
Mar 3, 2009

Dren posted:

I can't seem to find the project settings I need in KDevelop. It couldn't find the includes it needed so it prompted me to edit the custom include path, which I did, but now I can't get back to that menu.

I like the stuff I have figured out much better than Eclipse.

The best thing about KDevelop is that you don't need project settings. Everything you need is in the CMakeLists.txt file. You add include folders there, linking libraries, etc.

Dren
Jan 5, 2001

Pillbug

rhag posted:

The best thing about KDevelop is that you don't need project settings. Everything you need is in the CMakeLists.txt file. You add include folders there, linking libraries, etc.

I found what I was looking for, there is a dot file in my top level directory with the settings. I found it sort of weird that they'd have a GUI that pops up situationally but doesn't say "hey dummy edit this in the text file we're making because this GUI isn't coming back". I guess include paths are the only extra setting I need but I have an auto tools project not a cmake one so I won't get to experience whatever goodness you are describing.

Tetraptous
Nov 11, 2004

Dynamic instability during transition.
Interesting! So does this mean that if I have an existing CMake project, I can just point KDevelop at it and it'll just work?

I usually just use Emacs, but the various semantic/autocompletion modes always seem limited or hard to set up. KDevelop looks interesting, if it's not too much effort to try. Can I configure it to use Emacs key bindings in the editor?

Volguus
Mar 3, 2009

Tetraptous posted:

Interesting! So does this mean that if I have an existing CMake project, I can just point KDevelop at it and it'll just work?

I usually just use Emacs, but the various semantic/autocompletion modes always seem limited or hard to set up. KDevelop looks interesting, if it's not too much effort to try. Can I configure it to use Emacs key bindings in the editor?

Yes, it should "just work". As for Emacs mode, i don't know if it supports that (or what exactly this mode would mean to you), but you can configure the shortcuts.

Another decent IDE is QT Creator (which also supports CMake files, among other things). Version 2.8.1 found in Fedora 20 is actually surprisingly nice. I tried it some few years back and it sucked, but now i am actually using it for a week and all is fine and dandy.

Slurps Mad Rips
Jan 25, 2009

Bwaltow!

So brief question on the subject of types and unions in C++11. I'm attempting to pack several types to be no more than 16 bytes each (memory is extremely limited) on a 64-bit platform. These types are recursive (that is the union-like class that stores these possible values is in fact a possible object located within the classes it holds), so it is best to save space here, as otherwise I end up wasting 7 bytes per boost::variant. Additionally, the packed attribute breaks for GCC, and clang doesn't like it either for some reason, so I'm taking a different route.

So far each type that isn't an number looks something like

code:
struct type {
  std::unique_ptr<void> ptr; // this is actually a guaranteed type, not a void*
  std::uint32_t cap : 28; // capacity
  std::uint32_t len : 28; // length
};
And since the available types will never be more than 8, I figured I could pad the last byte with a std::bitset<8>, and have the bitset bits be the tag for the union. However, if I stick the bitset outside of the union, I end up with a 24 byte aligned structure (wasting, once more, 7 bytes)

My question is, if I were to add the bitset to each type (and wrap the integral types so that they are properly aligned), is it legal to access the 'bitset' member of each type directly, whether that specific type has been initialized? I was able to find this stackoverflow which gave me some hints that in this case, all the types would in fact meet the requirements in that the std::bitset<8> was always initialized and could therefore be accessed regardless of type as a member, and not invoke undefined behavior.

For safety's sake I'm going to assume no, as the compiler could technically reorder each type's location of std::bitset, and then I'd be boned, but I would like just a little bit of confirmation.

FamDav
Mar 29, 2008
types that can go into unions are PODs, which guarantees they have the same memory layout as C. If your bitset is at the start of each type, it will be accessible from all types when type-punning.

EDIT: to be pedantic, c++ unions accept some things which aren't PODs. Whatever your types are probably PODs

EDIT2: So you were unable to get something like

C++ code:
struct tagged_union {
	enum class TYPES : char { T0 = 0, T1 = 1, etc... };
	union {
		type0;
		type1;
		etc..
	};
};
working with minimal size?

FamDav fucked around with this message at 07:46 on Dec 11, 2013

Slurps Mad Rips
Jan 25, 2009

Bwaltow!

FamDav posted:

types that can go into unions are PODs, which guarantees they have the same memory layout as C. If your bitset is at the start of each type, it will be accessible from all types when type-punning.

EDIT: to be pedantic, c++ unions accept some things which aren't PODs. Whatever your types are probably PODs

EDIT2: So you were unable to get something like

C++ code:
struct tagged_union {
	enum class TYPES : char { T0 = 0, T1 = 1, etc... };
	union {
		type0;
		type1;
		etc..
	};
};
working with minimal size?

That was a data example, but these types are not PODs, nor are they trivial or standard layout. Additionally, I'd prefer to put the bitset at the end as everything else is taking up 15 bytes at the front. I'm worried about type punning within a union-like class with the relaxed C++ rules regarding unions.

GeneralZod
May 28, 2003

Kneel before Zod!
Grimey Drawer
More KDevelop love, here - its code completion/ navigation for C++ is really very good indeed. Plus (plug, plug) - it has a pretty capable Vim emulation mode, if that floats your boat.

Sauer
Sep 13, 2005

Socialize Everything!
I learned C++ back in college many years ago and pretty much never used it again once I left school. Most of my work, I'm just a hobbyist now, is done in Lua and C#. Is there a book that teaches C++ that is for folks who already know how to program? Is there one written from the ground up for C++11? Most of the books I've browse so far seem like new editions that just have a few chapters teaching C++11's new features.

GeneralZod
May 28, 2003

Kneel before Zod!
Grimey Drawer

DSauer posted:

I learned C++ back in college many years ago and pretty much never used it again once I left school. Most of my work, I'm just a hobbyist now, is done in Lua and C#. Is there a book that teaches C++ that is for folks who already know how to program? Is there one written from the ground up for C++11? Most of the books I've browse so far seem like new editions that just have a few chapters teaching C++11's new features.

From the blurb, it sounds like the 4th edition of Bjarne's own "The C++ Programming Language" might fit the bill - it's definitely aimed at programmers, and seems to have been re-written entirely to make use of C++11 (quote: "Throughout, Stroustrup presents concise, 'pure C++11' examples"). I've not read it myself, though.

Posting Principle
Dec 10, 2011

by Ralp
The C++ Primer was also rewritten entirely for C++11.

xgalaxy
Jan 27, 2004
i write code

Posting Principle posted:

The C++ Primer was also rewritten entirely for C++11.

This one is better than Bjarne's IMO.

bobua
Mar 23, 2003
I'd trade it all for just a little more.

DSauer posted:

I learned C++ back in college many years ago and pretty much never used it again once I left school. Most of my work, I'm just a hobbyist now, is done in Lua and C#. Is there a book that teaches C++ that is for folks who already know how to program? Is there one written from the ground up for C++11? Most of the books I've browse so far seem like new editions that just have a few chapters teaching C++11's new features.

I grabbed the Bjarne's latest book 6 months ago and really liked it. I knew what loops and variables were but was(am) in no way a programmer, wasn't even a painful read through even though it's probably more of a technical reference.

Sauer
Sep 13, 2005

Socialize Everything!
Both recommendations sound good; I'll check them out. Thanks folks.

Slurps Mad Rips
Jan 25, 2009

Bwaltow!

SAHChandler posted:

That was a data example, but these types are not PODs, nor are they trivial or standard layout. Additionally, I'd prefer to put the bitset at the end as everything else is taking up 15 bytes at the front. I'm worried about type punning within a union-like class with the relaxed C++ rules regarding unions.

Disregard my previous message, I forgot I have to support custom allocators, so this whole thing falls apart :v:

Dren
Jan 5, 2001

Pillbug
I have been coding in KDevelop for while today. Its code navigation and autocompletion are stellar and I am so glad I'm using it and not Eclipse with the CDT. KDevelop would be pure excellence if it had emacs key bindings but they have keyboard driven column editing (they call it block selection mode it's ctrl+shift+b) so they are forgiven. Basically this thing is awesome so thanks for recommending it.

hooah
Feb 6, 2006
WTF?
As a (more or less) beginner programmer, what are some differences I would notice/appreciate between NetBeans, Eclipse, and KDevelop? I've been using NetBeans this last semester at least once a week for labs and checking that what I've written in Visual Studio will run as expected on a Linux box.

Dren
Jan 5, 2001

Pillbug

hooah posted:

As a (more or less) beginner programmer, what are some differences I would notice/appreciate between NetBeans, Eclipse, and KDevelop? I've been using NetBeans this last semester at least once a week for labs and checking that what I've written in Visual Studio will run as expected on a Linux box.

Haven't used netbeans. Eclipse is slower than kdevelop. Eclipse's code parsing fails on more complicated stuff that works in kdevelop. I don't think eclipse even has auto completion but kdevelop is constantly offering to autocomplete stuff (If you feel that it's autocompleting too much you can configure it to only autocomplete when you hit a button). KDevelop has a rad object hierarchy browser that shows you inheritance relationships (eclipse has nothing even remotely like this).

KDevelop looks like it has a lot more stuff too, like it might actually function with the custom make system in our project though I probably won't use that feature. If you let Eclipse auto-build for this project it will get all hosed up and be building forever because it can't figure out the make system.

If you're not working on a big project you probably don't need to be in an IDE. If I were working on an isolated component that I knew well or a from scratch component I'd probably use emacs instead of KDevelop because I like emacs as a text editor. But since I'm doing some work with code I'm not really familiar with having all the code navigation tools and autocompletion of the IDE is super helpful.

hooah
Feb 6, 2006
WTF?
Thanks for the information. I just installed it to check it out. Made a C++ terminal program called "Hello world", and the drat thing was already written for me. Except it wouldn't build because evidently it's looking somewhere for a directory called "world".

Marta Velasquez
Mar 9, 2013

Good thing I was feeling suicidal this morning...
Fallen Rib

Dren posted:

Haven't used netbeans. Eclipse is slower than kdevelop. Eclipse's code parsing fails on more complicated stuff that works in kdevelop. I don't think eclipse even has auto completion but kdevelop is constantly offering to autocomplete stuff (If you feel that it's autocompleting too much you can configure it to only autocomplete when you hit a button). KDevelop has a rad object hierarchy browser that shows you inheritance relationships (eclipse has nothing even remotely like this).

KDevelop looks like it has a lot more stuff too, like it might actually function with the custom make system in our project though I probably won't use that feature. If you let Eclipse auto-build for this project it will get all hosed up and be building forever because it can't figure out the make system.

If you're not working on a big project you probably don't need to be in an IDE. If I were working on an isolated component that I knew well or a from scratch component I'd probably use emacs instead of KDevelop because I like emacs as a text editor. But since I'm doing some work with code I'm not really familiar with having all the code navigation tools and autocompletion of the IDE is super helpful.

I make embedded Linux firmware. Every time I hit compile, I'm building an entire operating system using a cross compiler.

Because everything I do is in C with a cross compiler, all of my custom code use custom Makefiles.

I found that if I use the standard variables in the Makefile (CC, CFLAGS, etc.), KDevelop can find the proper directories. If I type:
C code:
#include <stdlib.h>
and mouseover or open it, it will open the stdlib.h of my cross compiler, not my PC.

It's nice to see what I'm actually using when I'm coding to uClibc but my PC is using glibc.

Dren
Jan 5, 2001

Pillbug

contrapants posted:

I make embedded Linux firmware. Every time I hit compile, I'm building an entire operating system using a cross compiler.

Because everything I do is in C with a cross compiler, all of my custom code use custom Makefiles.

I found that if I use the standard variables in the Makefile (CC, CFLAGS, etc.), KDevelop can find the proper directories. If I type:
C code:
#include <stdlib.h>
and mouseover or open it, it will open the stdlib.h of my cross compiler, not my PC.

It's nice to see what I'm actually using when I'm coding to uClibc but my PC is using glibc.

It's nice that KDevelop can infer from your makefiles what needs to happen. You can usually get that in other IDEs (KDevelop too) by messing about with include paths. My project builds inside a chroot so I have a non-standard way to get to the system headers/stl headers that can only really be solved by setting the include path.

Jinx
Sep 9, 2001

Violence and Bloodshed

Edison was a dick posted:

In my experience, most don't, instead opting to use their preferred text editor, make and GDB. To me, Linux itself is my IDE, though I've heard good things about Kdevelop recently.

QTcreator is pretty decent and even supports darker colour schemes. It's used primarily by the juniors. I'm a grumpy old man so I use vi(m) with NerdTree and ctags.

bobua
Mar 23, 2003
I'd trade it all for just a little more.

Is there any reason an error, specifically a divide by 0 error, would halt a thread instead of just crashing\actually throwing an error while debugging in vs2012?

The following code would very rarely result in a divide by 0, but would never say so. That particular thread would just freeze up. After compiling for release it would crash every time, which is what led me to discover it.

The exact same code is found elsewhere, but in the main thread, and would throw an exception.

code:
                        auto start = std::chrono::high_resolution_clock::now();
			//stuff
			auto finish = std::chrono::high_resolution_clock::now();
			auto microseconds = std::chrono::duration_cast<std::chrono::microseconds>(finish-start);
			int milliseconds = microseconds.count() / 1000;
			int fps = 1000 / milliseconds;

OneEightHundred
Feb 28, 2008

Soon, we will be unstoppable!
e: Oops those are ints, not float, ignore me.

OneEightHundred fucked around with this message at 03:25 on Dec 22, 2013

ctz
Feb 6, 2003

bobua posted:

Is there any reason an error, specifically a divide by 0 error, would halt a thread instead of just crashing\actually throwing an error while debugging in vs2012?

Possibly unrelated data point: a failing assert when using the multithreaded CRT:

a) stop that thread while a modal dialog is displayed
b) not stop other threads
c) not stop the process until the modal dialog is dismissed

But under debugging this should be different: you should get a SEH EXCEPTION_INT_DIVIDE_BY_ZERO raised.

movax
Aug 30, 2008

I think this might be the best place to ask, what's the cross-platform UI toolkit of choice these days? I want to write a Gerber viewer (gerbv frustrates me sometimes), and I figure I can vastly increase my potential userbase if it runs on Windows, Linux and OS X. My initial plan was to write it in C#, because I love Visual Studio and I'm pretty familiar with Windows development, but I don't know if Mono would be suitable to run it on OS X and Linux because I want to use some HW accelerated graphics stuff also.

I do know though, without a doubt, that I want to try and use the native widgets on every platform when possible (unlike GTK apps on Windows). wxWidgets, Qt? Or structure my code such that I have a core Gerber library in vanilla C or something, and then re-write the UI for each platform (eeek)?

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe

movax posted:

Or structure my code such that I have a core Gerber library in vanilla C or something, and then re-write the UI for each platform (eeek)?

This has really been the only workable approach. UI conventions differ between platforms, and that's why "cross-platform widget toolkits" always seem cheap. It's easy to abstract over a Button widget, but it's harder to abstract over Human Interface Guidelines.

shrughes
Oct 11, 2008

(call/cc call/cc)
From an end-user standpoint I've been happier with stuff made using Qt than stuff made using Gtk. A ton of stuff uses Qt, and yeah, the experience might not be piss-perfect compared to giving yourself 3x the UI work, but so many things use it and it works out pretty well. See also https://en.wikipedia.org/wiki/Category:Software_that_uses_Qt

When I was trying to do this wxWidgets seemed immature to me and Qt seemed mature, and if there's a trade-off I suspect it would be a heavier up-front learning curve of Qt (didn't seem bad to me, though) versus the long-running risk that wxWidgets isn't good enough (for what it's worth, my Gtk on Windows user experiences might have been partly caused by the fact that I only see Gtk on Windows used because the software was originally made for Linux). Somebody could probably come along to contradict me who has way more experience than me, all I was trying to do way-back-when was to get a not-too-complicated program wrapping OpenGL.

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed

shrughes posted:

When I was trying to do this wxWidgets seemed immature to me
One of wx's major problems is that it's too mature. The API is very 90s and clearly an attempt at doing MFC right.

For a user's perspective, GTK is terrible everywhere but Linux. wxWidgets is the best cross-platform option on Windows, but it's worse than Qt everywhere else. Qt is okay everywhere (except KDE-based linux, where it's native). Anyone who tries to tell you that you can write a good OS X GUI without using Cocoa via Objective-C is probably trying to sell you something.

Mono doesn't support WPF, so even if you only care about the program being runnable and not necessarily nice to use it's not a good plan for a GUI (gently caress winforms).

A core library with as much of the functionality as possible that's wrapped by a GUI is a pretty good design for an application even if you aren't going to write multiple UIs for it.

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
wxWidgets is a really bad wrapper trying to implement MFC on other platforms. Its documentation is littered with "this only works on PocketPC" (yes, it prides itself on its PocketPC port) and "this doesn't work on OS X", etc. all over the place.

Qt is really three or four different projects, all for building different kinds of UIs and on various kinds of systems.

GTK+3 works on Windows/Mac (we have three people maintaining it now), but it's a bit of a pain to compile right now, and we don't ship supported binaries. We do have some unsupported binaries over here.

However, it's not going to make a native-looking UI on all platforms. You do have to do your own work to follow the platform's HIG for every port. We do ship CSS themes for Windows and Mac that make them look more integrated, though.

Paniolo
Oct 9, 2007

Heads will roll.
Problem I've always had with Qt is how large and all-in it is; it provides its own implementation of everything and as such can be annoying to integrate with an existing codebase, and will bloat the absolute poo poo out of your build times / add tons of DLL dependencies. Wx has tons of problems, but it's a lot slimmer.

For a standalone project I think Qt is by far the best option out there, but wx has a niche for projects where you're making a tool using some existing code.

movax
Aug 30, 2008

Hmm, looks like I need to some research into how to strap a given library to various UI frameworks; conceptually it makes sense, but I'm not sure how to write the exact Obj-C or C# to say "hey, dude clicked Open File, pass byte stream over to libgerber for threaded parsing". Need to do more research in that arena.

Sauer
Sep 13, 2005

Socialize Everything!
Thanks to the advice of some of you I picked up Stroustrup's "The C++ Programming Language" and I've been plowing through it. Unbelievable how much has changed since I last used C++ in the mid 90s. For the heck of it I refactored some of my ancient Win32 code using lambdas and function objects and it "just works". Huge amounts of boiler plate code in my event handling methods just vanished! No point in doing that since there's no reason for me to ever use Win32 again, but it was still a fun mental project in using new features. RIP class member function pointers.

No real need to learn C++ for my day to day hobby work but its still refreshing to learn what is effectively a new language, keeps things fresh. Thanks again for the recommendation.

Sauer fucked around with this message at 08:05 on Dec 23, 2013

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe

movax posted:

Hmm, looks like I need to some research into how to strap a given library to various UI frameworks; conceptually it makes sense, but I'm not sure how to write the exact Obj-C or C# to say "hey, dude clicked Open File, pass byte stream over to libgerber for threaded parsing". Need to do more research in that arena.

Hm, so I just realized, could this be a web app? You can get the user to upload a file using an input form and FileReader, parse it in a Web Worker, and then render the view using HTML5 canvas.



(I wrote some stuff for GTK+ below, if you want to do a native desktop app)

The only potentially tricky thing about opening files is that users might want to load from the network, or from the their Google Drive, or from any number of "virtual" sources, so a lot of toolkits integrate a virtual filesystem layer. In GTK+ (the toolkit I know the most), at least, you can turn that feature off and say "please give me a filename on disk".

In GTK+, at least, this would be fairly simple. Get a simple app up, then wire up a GtkFileChooserDialog, then send the result of that over to libgerber. In order to not block the main UI thread, if libgerber doesn't do anything complicated with a thread yourself, you can use GTask to launch a blocking task on a worker thread and get notified when it completes.

If you need to do any custom rendering (rendering your PCB, for instance), you can use cairo together with a GtkDrawingArea.

movax
Aug 30, 2008

Suspicious Dish posted:

Hm, so I just realized, could this be a web app? You can get the user to upload a file using an input form and FileReader, parse it in a Web Worker, and then render the view using HTML5 canvas.



(I wrote some stuff for GTK+ below, if you want to do a native desktop app)

The only potentially tricky thing about opening files is that users might want to load from the network, or from the their Google Drive, or from any number of "virtual" sources, so a lot of toolkits integrate a virtual filesystem layer. In GTK+ (the toolkit I know the most), at least, you can turn that feature off and say "please give me a filename on disk".

In GTK+, at least, this would be fairly simple. Get a simple app up, then wire up a GtkFileChooserDialog, then send the result of that over to libgerber. In order to not block the main UI thread, if libgerber doesn't do anything complicated with a thread yourself, you can use GTask to launch a blocking task on a worker thread and get notified when it completes.

If you need to do any custom rendering (rendering your PCB, for instance), you can use cairo together with a GtkDrawingArea.

I thought about making it a web-app, but there's a security concern from the user side of uploading their design files to a remote server. Only way around this is if I eventually come out with a version that can be instanced & deployed internally on a corporate network or something like that, but I am not sure if I want to open-source just yet.

Re: File opening, I definitely want to use native widgets when possible for the reasons you've described; on Windows if they have Google Drive or Network drives, I want them to drag and drop the files in, or open the file using the Windows dialog; ditto for OS X/Linux. Maybe gerbv uses some rear end-old version of GTK+ (it doesn't do drag and drop at all, doesn't store recently used paths, etc), sounds like the newer one, while not actually calling the native dialog from shell32/etc, still delivers a pretty usable solution?

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
There doesn't need to be a server at all. You can make the webapp entirely client-side.

movax
Aug 30, 2008

Suspicious Dish posted:

There doesn't need to be a server at all. You can make the webapp entirely client-side.

Ah, client-side JS/HTML5? (I am not a web-app guy at all) So the source would be exposed on their side right?

I'm looking around for resources re: cross-platform development, and got a decent set of rules here so far, still looking around for more resources & examples.

Adbot
ADBOT LOVES YOU

roomforthetuna
Mar 22, 2005

I don't need to know anything about virii! My CUSTOM PROGRAM keeps me protected! It's not like they'll try to come in through the Internet or something!

movax posted:

Ah, client-side JS/HTML5? (I am not a web-app guy at all) So the source would be exposed on their side right?
Once it's minified, JS is barely more readable than decompiled compiled languages. I wouldn't be concerned, and I'm not an open-sourcey sort of person.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply