  Recent detection of sub-TeV emission from gamma-ray bursts (GRBs) represents
a breakthrough in the GRB study. The multi-wavelength data of the afterglows of
GRB 190114C support the synchrotron self-Compton (SSC) origin for its sub-TeV
emission. We present a comparative analysis on the SSC emission of GRB
afterglows in the homogeneous and wind environment in the framework of the
forward shock model. The $\gamma\gamma$ absorption of very high-energy photons
due to pair production within the source and the Klein-Nishina effect on the
inverse-Compton scattering are considered. Generally a higher SSC flux is
expected for a larger circum-burst density due to a larger Compton parameter,
but meanwhile the internal $\gamma\gamma$ absorption is more severer for
sub-TeV emission. The flux ratio between the SSC component and the synchrotron
component decreases more quickly with time in the wind medium case than that in
the homogenous-density medium case. The light curves of the SSC emission are
also different for the two types of media. We also calculate the cascade
emission resulted from the absorbed high-energy photons. In the ISM environment
with $n> 1\,\rm cm^{-3}$, the cascade synchrotron emission could be comparable
to the synchrotron emission of the primary electrons in the optical band, which
may flatten the optical afterglow light curve at early time ($t<1$ h). In the
wind medium with $A_{\ast}> 0.1$, the cascade emission in the eV-GeV band is
comparable or even larger than the emission of the primary electrons at early
time.
