I don't think you want either of these lenses for your stated purposes of macro and portrait . They'll work, but not necessarily be most ideal. (As dpollitt also notes, see Is a macro lens suitable for distant subjects - wildlife, sports, portraiture?.)
First, normal and wider macro lenses are used for document reproduction, but not usually for the kind of insect or nature or whatever macro photography people usually get interested in. For those, you usually want a longer lens, because that gives you a good working distance — more on that here. The working distance for true 1:1 macro with the 40mm is just 3-4cm from the front of the lens! So, you probably want something like a 90mm or 100mm macro. (Or 60mm — Nikon makes a decently-regarded and relatively low cost 60mm f/2.8.)
Also echoing dpollitt, on APS-C, anything in that same range makes a nice focal length for portraits. Of course, any focal length, can take portraits, but traditionally this is the sweet area for easily flattering results. (More on that at Which focal-length lens is usually used for portrait photography, and why?). 35mm and 40mm on APS-C give a focal length that's just below that traditional portrait range — pretty decent for full-body shots or maybe a little closer, but too wide for the classic portrait lens.
So, I think if I were you, I'd start there — somewhere with a longer focal length. Then, either of the 35mm or 40mm would be a nice complement than that. (You can never have too many lenses, right?)
As for which if these to get for general shooting... They're both fine value-priced options. I've only used the 35mm, but as I understand the consensus, the 40mm is a bit sharper and had a nicer rendering of out of focus areas (bokeh) — while the 35mm saves you $75 and gets you a little over a stop more light. The sharpness shouldn't really be a deciding factor for general use (both are fine and sharpness is often overrated), and with today's great high-ISO sensors I wouldn't sweat the speed difference either. (Sure, faster is better, but so is getting more of the scene in focus, and even f/2.8 gives too-shallow depth of field for typical indoor scenes if you have more than a single subject dominating the composition.)
I shoot with a 40mm on my Pentax APS-C DSLR all the time, and find it a very useful and versatile focal length. However, indoors, I do sometimes wish for just a few degrees more field of view, as 35mm would give you. Again, this comes down to six of one and half a dozen of the other. You might try renting both lenses for a bit and deciding which fits you best after a week or two of shooting with each.