Ispell and flyspell are two packages. Setup of ispell has no effect on flyspell. (flyspell does use very limited ispell APIs but it should be invisible to users).
In your case, "iostream" is checked because its font face is font-lock-string-face
. By default, flyspell-prog-mode
is used for any major-mode inherits from prog-mode
(for example, c++-mode
inherits from prog-mode
).
Read the code of flyspell-prog-mode
, you will find flyspell-generic-progmode-verify
is used as predicate. It basically just check whether font face of word matches pre-defined font in flyspell-prog-text-faces
whose default values is '(font-lock-string-face font-lock-comment-face font-lock-doc-face)
.
So there are two simple solutions:
Solution 1, don't check words inside string
but do check comments
and doc
:
(setq flyspell-prog-text-faces '(font-lock-comment-face font-lock-doc-face))
Solution 2 (recommended), do check the word inside string
but tell the spell checker (aspell or hunspell) that "iostream" is not typo. If you use aspell, please edit ~/.aspell.en.pws
, add a new line containing one word "iostream". For hunspell setup, check http://www.suares.com/index.php?page_id=25&news_id=233
Here is sample .aspell.en.pws
containing all C++ header file names:
personal_ws-1.1 en 63
algorithm
array
bitset
cassert
cctype
cerrno
cfenv
cfloat
cinttypes
ciso646
climits
clocale
cmath
complex
csetjmp
csignal
cstdarg
cstdbool
cstddef
cstdint
cstdio
cstdlib
cstring
ctgmath
ctime
cwchar
cwctype
deque
exception
fstream
functional
iomanip
ios
iosfwd
iostream
istream
iterator
limits
list
locale
map
memory
new
numeric
ostream
queue
random
regex
set
sstream
stack
stdexcept
streambuf
string
strstream
tuple
typeinfo
type_traits
unordered_map
unordered_set
utility
valarray
vector
BTW, I don't use flyspell-prog-mode
at all because it's too primitive and use less than 1% of Emacs power. I prefer tweak the spell checker options by myself and write my own predicates per major-mode.
How to tweaking spell checker options: http://blog.binchen.org/posts/what-s-the-best-spell-check-set-up-in-emacs.html
My predicate sample: https://github.com/redguardtoo/emacs.d/blob/master/lisp/init-spelling.el
My answer on write predicate for markdown-mode: How to make Flyspell ignore code blocks in Markdown?