The $$ in the gcc line, I believe, will be different from the one in the sed line, so your sed will be operating on a different file from the one generated by the gcc. Try storing $$ into another variable and then using that everywhere.
It looks like you're just using $@.$$$$ very briefly as a temporary file, whose name doesn't matter.
Why not use a different name that doesn't use dollar signs?
$@.TEMP
Or even the same filename for every rule, with no $s or @ at all, since it will be deleted before the next command begins.
BTW, I trust you are working on Makefile rules, though you never mentioned it.
yes indeed, I am working on a makefile - sorry for not having mentioned that earlier.
I actually replaced $@.$$$$ with $@.tmp and it did work, so you're right. but I was stuck upon understanding why it shouldn't work with the $'s.
It seems like what JerryHone mentioned regd. the sed and gcc having a different $$ value could be the problem - trying to play around with that.