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
Vanadium
Jan 8, 2005

UberJumper posted:

So i saw this today from ERDAS's software SDK...

code:
#define __(a) a
What the gently caress?

I was curious because they prototype their functions like:

<type> <function name> __((<parameter list>))

It is so they can change it to #define __(a) () to support C compilers that do not implement function prototypes, I suspect.

Adbot
ADBOT LOVES YOU

Vanadium
Jan 8, 2005

RussianManiac posted:

I am confused. Isn't a prototype just a function declaration without its implementation?

It is, basically. But in C before prototypes, you would not give the parameter list when declaring functions.

Vanadium
Jan 8, 2005

How many programmers are there targetting it, though, compared to all of us plebs writing PC or web apps in perl?

Vanadium
Jan 8, 2005

WoW does not even obey the triangle thing because you cannot travel in straight lines most of the time. :colbert:

Vanadium
Jan 8, 2005

Tell me more. :colbert:

Vanadium
Jan 8, 2005

code:
dcopid=$1

euro=0;
cent=0;
for line in `dcop $dcopid KommanderIf text snack_scanfield|sed -e :0 -e s/".("/"("/ -e t0 -e s/"("// -e s/")"//`; do
if [ "x$(echo $line|cut -d- -f1)" == "x" ]; then
multiplier="-"
else
multiplier="+"
fi
euro=$(($euro $multiplier `echo $line|cut -d\. -f1|sed -e s/"-"//`))
cent=$((`echo $line|cut -d\. -f2|sed -e s/"^[0]*"//` $multiplier $cent))
done
echo $cent;
while [ $cent -ge 100 ]; do
euro=$(($euro+1))
cent=$(($cent-100))
done
while [ $cent -le -100 ]; do
euro=$(($euro-1))
cent=$(($cent+100))
done
if [ $cent -lt 0 ] && [ $euro -ge 0 ]; then
euro=$(echo -$euro)
cent=$(echo $cent|sed -e s/"-"//)
fi

if [ $cent -gt 0 ] && [ $euro -lt 0 ]; then
euro=$(($euro + 1))
cent=$((100 - $cent))
fi

dcop $dcopid KommanderIf setText snack_bookingprice "$euro.`printf %02d $cent`"
unix programming is the best programming :allears:

Vanadium
Jan 8, 2005

Clearly degrees and radians ought to be given in separate types so that trigonometric functions can be overloaded on them.

Vanadium
Jan 8, 2005

No, it would not, it would be perfectly fine, except nobody expects to have to do that when given a const reference, or any reference at all.

Vanadium
Jan 8, 2005

jandrese posted:

How were foo1 and foo2 declared? Dynamically? Maybe someone's trying to avoid a race condition or memory leak?

How the hell do you declare something dynamically

Vanadium
Jan 8, 2005

If you really want something that approaches a REPL for C++, why not go the whole distance and turn it into an IRC bot.

:colbert:

Vanadium
Jan 8, 2005

code:
int EntrySortFunc(const void *pEl1, const void *pEl2) {
  Entry *pEntry1 = *(Entry * const *) pEl1, *pEntry2 = *(Entry * const *) pEl2;
  [...]
// sort folders before files
  bool fS1, fS2;
  if (!(fS1=!pEntry1->GetIsFolder()) != !true != !(fS2=!pEntry2->GetIsFolder())) return fS1-fS2;
:psyduck:

Vanadium
Jan 8, 2005

king_kilr posted:

The real coding horror is not knowing the difference between strong/weak typing and static/dynamic typing.

var is neither weak nor dynamic. :colbert:

Vanadium
Jan 8, 2005

Janin posted:

:psyboom:

Clearly that should be:

code:
fstream file_stream(file_path.c_str());
stringstream file_xml;
file_xml << file_stream.rdbuf();

stringstream rm_cmd;
rm_cmd << "rm -f " << file_path;
system(rm_cmd.str().c_str());

string xml = file_xml.str();
:colbert:

Vanadium
Jan 8, 2005

Mista _T posted:

My guess is that the guy is or used to be a C++ programmer (where "new" is basically malloc plus constructor).

It still never returns NULL, unless you turn off exceptions or do something crazy like that.

Vanadium
Jan 8, 2005

Nomnom Cookie posted:

"Array" is not vague terminology in C, C++,

So I guess I will be okay if I dynamically allocate enough memory for N objects of type T and just have a pointer to them instead of declaring a T[N]?

Vanadium
Jan 8, 2005

How is the former an array?


vvv that just means you access the elements of actual arrays through a pointer, it does not make everything you can point to an array

Vanadium fucked around with this message at 16:56 on Mar 18, 2010

Vanadium
Jan 8, 2005

I would consider keeping the maths out of the loop head

Vanadium
Jan 8, 2005

Why the hell would java care whether you pre- or postincrement anything

Vanadium
Jan 8, 2005

What is everybody's favourite program/its configuration to reformat C++ code? :allears:

Vanadium
Jan 8, 2005

HFX posted:

code:
int c;
while ((c = getchar ()) != EOF)
   {
     unsigned char u = c;
     write (file_descriptor, &u, 1);
   }
Yes an actual recommendation to coerce to a smaller type without an explicit cast. I know C lets you. It usually is not a good idea.

But... getchar() only ever returns values in the unsigned char range, except for when it returns EOF, so what could possibly go wrong?

Vanadium
Jan 8, 2005

mr_jim posted:

That pretty much sums up all of the MUMPS code posted in this thread.

or anywhere else

Vanadium
Jan 8, 2005

With spaces, because that is not indentation.

Vanadium
Jan 8, 2005

Spaces are better than tabs because vim's auto-indent keeps loving up the case that Janin is describing :ohdear:

Vanadium
Jan 8, 2005

What if I do not use the standard library? :smug:

Vanadium
Jan 8, 2005

Should be char name[MAX_SIZE] = "Default";, I guess.

Vanadium
Jan 8, 2005

Yeah, it is, if you initialise an array but do not give values for all the elements, the remaining ones get set to zero.

Vanadium
Jan 8, 2005

It would work for reasonably short strings (or if you have reasonably big integers) if you multiply each n'th character's value by 256 to the n'th power. :colbert:

Vanadium
Jan 8, 2005

Well it is more exciting

Vanadium
Jan 8, 2005

shrughes posted:

They'll need a bigint class for that, they could implement it as a char array, they'll just have to implement integer comparison.

Luckily, we already have a function for that, or so goes the intuitionistic introduction to recursion.

Vanadium
Jan 8, 2005

In its defense, javascript 101 is somewhat retarded

Vanadium
Jan 8, 2005

What manner, unexpected type coercion shenanigans?

Vanadium
Jan 8, 2005

baquerd posted:

This doesn't work :colbert:

Sounds like you are not using AnyBrowser. :smug:

Vanadium
Jan 8, 2005

It is when you do a syscall and the syscall is happily doing its thing and nothing is going wrong and then it suddenly returns -1 anyway because you received a signal or something dumb, and then you have to just do the same thing again and hope you do not get a syscall this time. Or a timeout, or whatever.

Vanadium
Jan 8, 2005

I am trying to decide whether perl or php's behaviour annoys me more than having to explicitly convert integers when I want to multiple them with doubles in haskell, help me out here.

Vanadium
Jan 8, 2005

Vino posted:

If they don't understand Subversion (which has an arguably easy to use Tortoise interface) then I doubt they would comprehend git/merc much less use it properly.

I had much easier time coming to terms with the whole decentralised thing than with svn, probably it was easier to just create a throwaway repository to play around in. v:shobon:v

Vanadium
Jan 8, 2005

Did the C++ thread not just tell a guy to go ahead with lots of string comparisons instead of bothering with a hashmap or whatever

Vanadium
Jan 8, 2005

Just having a single expression inside each branch of an if-then-else expression has always worked fine for me, I do not see what the big deal is

how do curly braces play into this again

Vanadium
Jan 8, 2005

*"" is '\0', typeof('\0') is char, (char**) is a cast to pointer to pointer to char, and the * dereferences it so you get a pointer to char to pass to puts, which happens to point at successive elements of argv.

Vanadium
Jan 8, 2005

Is it okay if you do that but also use inner classes?

Adbot
ADBOT LOVES YOU

Vanadium
Jan 8, 2005

So it is dead-code analysis that gets broken by dead code?

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