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
Doc Block
Apr 15, 2003
Fun Shoe

Remulak posted:

I'm trying to think about cross-platform Windows/Mac compatibility for a the backend of a new project I've been working on. It's not a horribly complex project, since it's just a common C++ backend to a client that will have its own native frontends, but drat it's hard to figure out a good cross-platform way of doing things I'd normally lean on an MS API for.

What's bugging me now is package handling - ideally I need to deal with a zip file with some pictures, binary resources, text, and metadata. My first thought was OpenXML, specifically Open Packaging Convention, which is MADE for this and has a nice API. My second thought was *oh gently caress*, this won't work on the Mac. While it's submitted for standardization it doesn't look like there's a Mac or specific cross-platform C++ approach.

Is there a good, standard way to deal with this kind of problem from non-platform-specific C++? Or hell, some OPC solution for the Mac if we have to break this up? It seems kind of stupid to roll my own implementation for this, I can't believe it hasn't been solved before...

For accessing the contents of a zip file, you could try zziplib or PhysicsFS.

Doc Block fucked around with this message at 06:54 on Feb 17, 2008

Adbot
ADBOT LOVES YOU

Doc Block
Apr 15, 2003
Fun Shoe

Jo posted:

I've heard performance takes a serious hit when it comes to using immediate mode (a la glBegin() and glEnd()) versus using display lists.

If I'm rendering geometry that moves, changes textures, and has dynamic lighting, can I still use display lists?

Yeah, display lists are faster.

The fastest way, however, would be vertex arrays or VBOs.

Doc Block
Apr 15, 2003
Fun Shoe
NM, reposting in Mac dev thread.

Doc Block fucked around with this message at 15:12 on Feb 19, 2008

Doc Block
Apr 15, 2003
Fun Shoe

freddy-10eighty posted:

I'm currently taking an intro to C++ at my uni.... can anyone tell me how to compile and run C++ files on a mac? I've tried using XCode, and it's a bit overwhelming since I'm still new to this...basically, when I write code, compile and build in MS Visual studio, a console window pops up and allows me to test out my program, but the same thing doesnt happen with XCode...nothing pops up.

It's a difference between the way Windows and Unix systems (including OS X) work when it comes to command-line vs GUI apps.

If you want to see your program's output, open up Terminal.app (it's in /Applications/Utilities), cd to yourprojectdir/build/(Release or Debug)/yourproject.app/Contents/MacOS and then type ./yourproject to run it.

Or, for simple little CLI programs don't bother with a big IDE like Xcode and just run g++ from the command-line.

Doc Block fucked around with this message at 11:29 on Feb 21, 2008

Doc Block
Apr 15, 2003
Fun Shoe
If GCC can find stdlib.h but isn't linking in all the functions from the C standard library then something is wrong with your setup. You shouldn't need any extra command-line options to get the stuff in stdlib.h to work.

Doc Block
Apr 15, 2003
Fun Shoe
putchar and getchar only do one character at a time and don't do any format conversion.

For example:
code:
int answer;
printf("Type in the answer: ");
scanf("%d", &answer);
printf("You typed: %d\n", answer);

Doc Block fucked around with this message at 20:50 on Feb 22, 2008

Doc Block
Apr 15, 2003
Fun Shoe
You downloaded and installed the platform SDK, right? And followed Microsoft's instructions on how to set up VS Express to use it and have the ability to create Win32 apps, right? That should be all you need to utilize the Win32 API (Win32 API != MFC).

You would still lack a resource editor, but IMHO it would be far better to use VS Express and suffer without a resource editor than to go back to VS 6.0.

Doc Block
Apr 15, 2003
Fun Shoe
What's a good book for learning modern C++? I have both volumes of Thinking in C++, but they're pretty old. I haven't written any C++ in a long time, but will probably have to write something in C++ soon, and the problem is that I only half remember the language and the STL.

I can reread Thinking in C++ if need be, but I'd prefer something that also incorporates the new C++11 and C++14 stuff.

Any suggestions?

edit: none of the books listed in the OP look like they cover C++11 & C++14, at least not in any currently-shipping edition.

Doc Block fucked around with this message at 06:24 on May 14, 2015

Doc Block
Apr 15, 2003
Fun Shoe
Are you on Windows? Try changing the read mode to "rb" and the write mode to "wb".

Doc Block
Apr 15, 2003
Fun Shoe
edit: tl;dr It has to do with Windows line endings being different than Unix line endings, and thus not being the same as C's newline character ('\n'). Microsoft's C standard library converts between the two when reading/writing text files so that Windows C programs can still just treat line endings in text as the single '\n' newline character instead of having to use "\r\n". The "b" modes ("rb", "wb", "rwb", "ab") were created to tell the stdlib that it's dealing with a binary file and not to do any newline conversion. Microsoft's C++ standard library implementation does the same thing AFAIK.

If you're reading/writing binary files using the C standard library (fopen(), fread() etc.) then use "rb", "wb", "rwb", or "ab" in case somebody ever runs your code on Windows. Or, if you're using C++ and iostreams, make sure to specify the std::ios::binary flag.

Doc Block fucked around with this message at 10:25 on May 21, 2015

Doc Block
Apr 15, 2003
Fun Shoe
Or just change directory at run-time to the "codebase" directory. You could have it be passed in as an argument that, if present, the executable will change to the specified directory. That way, for testing/debugging within VS you can have it change to the "codebase" directory, and then for shipping you can just copy the release executable to the copy of "codebase" that you're shipping.

Doc Block fucked around with this message at 18:05 on May 31, 2015

Doc Block
Apr 15, 2003
Fun Shoe
You also have the problem of doing
C++ code:

if(n==100)
...
else if(n>=90&&n<=100)

when it should be
C++ code:

if(n==100)
...
else if(n>=90&&n<100)

or even just
C++ code:

if(n==100)
...
else if(n>=90)

since n is guaranteed to be less than 100 if control reaches the else if statement.

Doc Block
Apr 15, 2003
Fun Shoe
They might have just parsed out the 80-bit format. Or it might be the size of the largest float the old non-Intel Mac FPU could do, like the x87 FPU did.

Doc Block
Apr 15, 2003
Fun Shoe
I have a kinda weird question: why do so many C++ developers make their for loops use prefix increment instead of postfix increment? In other words, why do they use ++i instead of i++? Like,
C++ code:
for(auto i = 0; i < whatever; ++i)
instead of the more "normal"
C++ code:
for(auto i = 0; i < whatever; i++)
?

I'm an Objective-C programmer, and I almost never see prefix increment in Objective-C or C code, and I don't recall it being used terribly often when I first started using C++ back in the early 2000s, but now that I'm trying to re-learn C++ I see it quite often in online C++11 examples and such.

Doc Block
Apr 15, 2003
Fun Shoe
I see, thanks. Having to get used to a language where class instances can be created on the stack and iterators are separate objects is kinda weird after so many years of writing Objective-C.

Does the C++ compiler have to create temporary variables even for integer indexes? Like, when compiled without optimizations, is there still a difference between
C++ code:
int limit = whatever
for(int i = 0; i < limit; i++)
and
C++ code:
int limit = whatever
for(int i = 0; i < limit; ++i)
?

edit: With integer indexes, clang seems to generate the same code for prefix and postfix. Gonna be different for iterators though, thanks for the info.

Doc Block fucked around with this message at 18:14 on Jul 22, 2015

Doc Block
Apr 15, 2003
Fun Shoe
Just another argument against operator overloading, heh :haw: :clint:

Doc Block
Apr 15, 2003
Fun Shoe

fritz posted:

quote:

You can also check out the very latest version via anonymous cvs. Here's how:

cvs -d:pserver:anonymous@cvs.gna.org:/cvs/gdsl co gdsl

:stonklol:

Doc Block
Apr 15, 2003
Fun Shoe

Xarn posted:

Can someone explain that to someone lucky enough to get started with git as source control?

CVS is old and terrible, and there's absolutely no reason to use it these days; there's Subversion if you need/want a centralized version control system that's open source and non-awful.

That they're using CVS says a lot of terrible things about their project.

Never mind that they're hosting it on a Free Software version of SourceForge.

Doc Block
Apr 15, 2003
Fun Shoe

hackbunny posted:

CVS is a positively ancient revision control system. How bad is it, really? Revision numbers are per-file, forget atomic commits. Forget history-preserving moves and copies in fact. Good luck bisecting, without atomic commits you have to work with loving timestamps. Good loving luck branching and merging. Can't even delete directories, the client has an option to automatically clean up empty directories. Advantages (or: how worse could it have been?): unlike its predecessor, RCS, it's client-server

Fun fact: CVS uses RCS for the actual versioning, which is why it's per-file, and also why it can silently corrupt your version history.

Doc Block
Apr 15, 2003
Fun Shoe
Swift still has operator overloading. :colbert:

Doc Block
Apr 15, 2003
Fun Shoe

JawKnee posted:

Hmm, yeah it appears so. So many deprecated functions!

Nothing in your shader accesses the fixed-function matrices anyway.

Compute the matrixes you need on the CPU, since you typically only need to change them once per frame, and sometimes even less often than that (like the projection matrix), and pass them into your vertex shader as uniforms. That way you aren't recomputing them for every vertex.

Pass in the modelViewProjection matrix, plus occasionally the model matrix and/or viewProjection matrix and a normal matrix depending on what lighting effects etc you're going for.

And you'll save yourself a lot of headaches in the future of you learn the difference between the model, view, and projection matrix (and why the OpenGL fixed-function pipeline combined the model & view matrices into one modelView matrix). I speak from experience :)

Doc Block
Apr 15, 2003
Fun Shoe

PRADA SLUT posted:

I noticed that after. It still outputs correctly.

Which is purely accidental.

Doc Block
Apr 15, 2003
Fun Shoe
If you want just C then I think your options are GTK and, uh... Motif?

Doc Block
Apr 15, 2003
Fun Shoe

Ciaphas posted:

The difference seems to only matter on systems where the file position isn't necessarily equal to the character count for text data. Are these some arcane platforms where this happens, or is this referring to Unicode data, or what? I only ever deal with ASCII or pure binary (mostly the latter) in my work so Unicode is just a word to me.

Isn't it mostly because on Windows the C runtime translates the \r\n into just \n when reading files opened in text mode, and vice-versa when writing, because Windows uses CR+LF for newline instead of just LF?

I remember being bitten by that years ago when trying to port some code written for Linux to Windows that sloppily opened all files in text mode, regardless of whether they were text or binary.

edit: and also for mainframe operating systems and their weird character sets too, I guess.

Doc Block fucked around with this message at 04:47 on Mar 1, 2016

Doc Block
Apr 15, 2003
Fun Shoe

bollig posted:

So as I understand it, if it's char *, it's just in memory aaaand immutable, I think. Whereas char[] is an array with characters as the elements.

char * is a pointer to a char, that's all, but is usually understood to be a pointer to an array of chars (such as a NULL-terminated string). When it comes to function arguments, char[] is basically the same thing, only you're being more explicit in your code about what the intent is: you want an array of chars.

Either can be used to pass a char array, and in fact pretty much every C function that takes a string will take a char * or const char *.

I forget what the exact term is, but passing an array in C results in it devolving into a pointer and the pointer being passed instead.

Such as:
C code:
#include <stdio.h>
#include <string.h>

void array(char *arr)
{
	if(strlen(arr) > 3) {
		arr[2] = 'Z';
	}
}

int main(int argc, char **argv)
{
	char string[] = "Hello, world!"

	printf("Before: %s\n", string);

	array(string);

	printf("After : %s\n", string);

	return 0;
}

Doc Block fucked around with this message at 18:06 on Mar 18, 2016

Doc Block
Apr 15, 2003
Fun Shoe
:munch:

Doc Block
Apr 15, 2003
Fun Shoe
It's probably pretty common for open world games and such to keep one or more background threads spun up that just handle loading data and streaming it to the GPU or whatever.

Doc Block
Apr 15, 2003
Fun Shoe
Try naming it LAST_VALUE or something so at least people don't have an excuse for adding things after it?

Doc Block
Apr 15, 2003
Fun Shoe
Are they really? LMFAO

Doc Block
Apr 15, 2003
Fun Shoe
If your application is GPL or LGPL (OP said it's an open source application), then I don't see why you couldn't just put the class files in your project and call it a day.

"Users" will still be able to swap out the KDE stuff with a newer version or whatever since the source will be available, etc

edit: has anyone ever actually swapped out a .DLL or .framework or whatever of an LGPL library that shipped with a closed-source application?

Doc Block fucked around with this message at 15:08 on Jun 2, 2016

Doc Block
Apr 15, 2003
Fun Shoe

leper khan posted:

Because the GPL is a legal virus that you may not want your code infected with? You can't just copy pasta code like that without thought.

Yes, I'm aware of that, which is why I said if his application was going to be licensed under the GPL or LGPL. He mentioned right there in his first post that he was going to make his application open source.

Now that he's said he wants to license it under MIT then yeah, obviously, he can't just copy/paste the files without serious legal consideration.

Doc Block
Apr 15, 2003
Fun Shoe
I saw some JavaScript (I think?) code where the programmer had done the equivalent of something like:
code:
if(!thing == false)
because the ! would essentially be converting it to a bool, that way the equality test would be a True Boolean Comparison :rolleyes: and then I discovered that this is apparently a thing with web developers :stonk:

I recall also seeing stuff where they would do if(!(!thing)) for the same dumb reason.

The moral of the story: just compare against what you're trying to compare against. So if you want to test if a float is nonzero, just do if(f != 0.0f) or if(f) or whatever.

Doc Block fucked around with this message at 08:48 on Aug 8, 2016

Doc Block
Apr 15, 2003
Fun Shoe
Yeah, I can understand doing !!integer as a short way to force an integer value to be 0 or 1, or if for some weird reason you really needed the comparison to be against 0 or 1 instead of zero/nonzero, but I was more poking fun at cargo cult web developers doing it needlessly in comparisons, like if(!thing == false) instead of just if(thing) because somehow doing a "true boolean comparison" (a thing a web developer actually told me) was somehow better or faster.

Guess it was only tangential to the point, which was that the OP should just write if(!myFloat) or if(myFloat == 0.0f) and be done with it, as opposed to trying to micro-optimize it or casting it to a bool first as a hint to the compiler etc. etc. etc.

Doc Block fucked around with this message at 08:56 on Aug 8, 2016

Doc Block
Apr 15, 2003
Fun Shoe
When it comes to JavaScript, who knows? v:shobon:v

But :doh: at True Boolean ComparisonTM. Even if that really is a faster/better way of doing it in JavaScript, I got the distinct impression he was just cargo culting.

Doc Block
Apr 15, 2003
Fun Shoe
Using glib even on *nix should be grounds for being fired (or kicked off the open source project).

Does it still call abort() when it encounters an error?

Doc Block
Apr 15, 2003
Fun Shoe
Click on a line number to set a breakpoint on that line in Xcode. Clicking on the little breakpoint arrow that appears over the line number will leave the breakpoint there but disable it (click on it again to re-enable); right click on it to bring up a contextual menu that will let you completely remove that breakpoint.

Doc Block fucked around with this message at 05:36 on Aug 19, 2016

Doc Block
Apr 15, 2003
Fun Shoe
You've built a 64-bit x86 slice (OS X allows multiple archs in the same binary), but either haven't linked everything to that slice (IDK if that's even possible) or you've got some prebuilt libraries you're linking against that don't have x86-64 slices.

Doc Block fucked around with this message at 23:07 on Sep 3, 2016

Doc Block
Apr 15, 2003
Fun Shoe

raminasi posted:

I just checked the prebuilt binaries with file, and it says "Mach-O 64-bit dynamically linked shared library x86_64," so I think I've got the right architectured ones, anyway. I also dumped the symbols of one of them with nm, but I can't really tell whether there are matches or not because ld gives me de-mangled symbols and nm gives me mangled ones. There are definitely plausible match candidates. I feel like there's just some stupid switch I need to set that I forgot about but I'll be damned if I can figure out what it is.

The error message you got specifically means that the linker can't find all the necessary symbols to link the x86-64 binary slice, which means something isn't getting compiled for x86-64.

You should be able to look at the list of missing symbols and figure out what library or whatever they're supposed to come from, then check that to make sure it's getting built for x86-64.

Doc Block
Apr 15, 2003
Fun Shoe

raminasi posted:

Yes, that is what I did, and they are, assuming that's what that output from file means.

Is the fact that they're dynamic libraries wrinkling something here?

Is it actually getting linked against those libraries, then? Is every symbol from that library missing, or just some of them?

I wouldn't think them being dynamic libraries would affect compile-time linking unless the linker can't find them (or isn't being told to link to them).

Adbot
ADBOT LOVES YOU

Doc Block
Apr 15, 2003
Fun Shoe
Yeah, CMake isn't the same thing as make. CMake is so you can generate project files for many different build systems, such as VS, Xcode, and makefiles for Linux etc.

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